Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Power Query Number.PositiveInfinity: How to Use It

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

The Number.PositiveInfinity function in Power Query returns the special numeric value that represents positive infinity. You use it as a constant in M formulas, usually to set an upper bound that no real number can exceed, such as a filter threshold, a cap in a custom column, or a default value when a calculation overflows. It takes no arguments, so you call it as Number.PositiveInfinity without parentheses. There is also a matching Number.NegativeInfinity for the opposite end of the scale, and Number.IsInfinity to test whether a value is infinite. Everything below applies to the Power Query Editor in Excel and to Power BI Desktop, which share the same M engine; menu labels can differ slightly by version and region.

What You'll Need

  • A version of Excel with Power Query (Excel 2016 and later on Windows, or Microsoft 365) or Power BI Desktop. The function is part of the core M library and needs no add-in.
  • A query open in the Power Query Editor, or a blank query where you can type M code directly.
  • Basic familiarity with the formula bar and the Advanced Editor, since the function is written in M rather than clicked from a menu.

Step-by-Step

  1. Open the Power Query Editor. In Excel, select a cell in your data and go to Data > Get & Transform Data > From Table/Range. In Power BI Desktop, use Home > Transform data. If you just want to experiment, create a blank query with Home > New Source > Blank Query.
  2. Decide where the value belongs. Positive infinity is most often used in one of three places: a filter condition, a custom column formula, or a step in the Advanced Editor. Pick one before you start typing.
  3. Type the function in the formula bar. Select the step you want to edit, click the formula bar, and enter Number.PositiveInfinity. For a quick test, create a blank query and type = Number.PositiveInfinity in the formula bar. Press Enter. The preview shows the word Infinity rather than a numeric literal, which is expected.
  4. Use it as an upper bound in a filter. A typical pattern is Table.SelectRows(Source, each [Amount] < Number.PositiveInfinity). This keeps every row whose Amount is a finite number or negative infinity but drops rows where Amount is itself positive infinity. In practice this is a way to exclude overflow values from a column.
  5. Use it in a custom column. Add a custom column with a formula such as if [Value] = null then Number.PositiveInfinity else [Value]. This replaces blanks with an infinite sentinel so later comparisons treat missing values as larger than any real number. Change the column type to Decimal Number or Int64 afterwards so the values display consistently.
  6. Use it in the Advanced Editor. Open Home > Advanced Editor and add a step such as UpperBound = Number.PositiveInfinity, then reference UpperBound in later steps. This keeps the threshold in one place and makes the query easier to read.
  7. Test the result with Number.IsInfinity. Add a step like Table.AddColumn(Source, "IsInf", each Number.IsInfinity([Value])) to confirm which rows carry an infinite value. The function returns true or false, which is easier to audit than eyeballing the word Infinity.
  8. Check the data type. Right-click the column header and confirm it is set to Decimal Number or a whole-number type. If the column is typed as Text, the infinity value will not compare correctly against numbers and your filters may behave unexpectedly.
  9. Close and load. Use Home > Close & Load (Excel) or Home > Close & Apply (Power BI) to push the result back to your workbook or model. Infinite values survive the load as the special infinity value in the destination, not as text.

Common Mistakes

Adding parentheses, as in Number.PositiveInfinity(), causes an error because the function takes no arguments; write it bare. Typing the word Infinity as a string in a Text column is another frequent slip: it looks right in the preview but will not behave like a number in comparisons or aggregations. Mixing data types in a column that contains infinity, such as text and numbers together, leads to filters that silently drop rows. Assuming infinity equals a very large number is also wrong: no finite value equals it, and arithmetic such as Number.PositiveInfinity - Number.PositiveInfinity produces NaN, not zero. Finally, do not expect the value to round-trip cleanly through every export format; CSV and some database drivers cannot represent infinity and may write it as an empty field or an error.

Tips

Use positive infinity as a sentinel for "no upper limit" in parameter tables so a single query can serve both capped and uncapped scenarios. Pair it with Number.NegativeInfinity to build a full range check, and with Number.IsNaN when your data also contains undefined results from division. If you need a finite stand-in for compatibility with a downstream system, replace infinity with a large but real number such as 1E+308 using if Number.IsInfinity([Value]) then 1E+308 else [Value], and document why. Keep the threshold as a named step rather than repeating the function in many formulas, so a future change is a one-line edit.

Troubleshooting

If the formula bar rejects your entry, check for a stray equals sign or parentheses and confirm you are editing an M step, not a DAX formula. If the preview shows an error instead of Infinity, the column is probably typed as Text; change the type and refresh. If a filter that uses infinity returns no rows, verify the comparison direction and that the column is numeric. If the value disappears after loading, the destination may not support infinity: test with a small table, and substitute a finite sentinel if needed. When results look stale, refresh the query and, if that fails, restart Excel or Power BI Desktop before rebuilding the step.

Frequently Asked Questions

Does Number.PositiveInfinity take any arguments?

No. It is a constant-style function called without parentheses, and passing arguments produces an error.

What is the difference between positive infinity and a very large number?

Positive infinity is larger than every finite number and is a distinct value in M. A very large number such as 1E+308 is still finite and can be exceeded by arithmetic.

How do I check whether a value is infinite?

Use Number.IsInfinity, which returns true for both positive and negative infinity. To distinguish the sign, compare the value against zero.

Can I use Number.PositiveInfinity in a custom column?

Yes. It works in any M expression, including custom column formulas, filters, and the Advanced Editor, as long as the column is typed as a number.

Why does my exported file show a blank instead of Infinity?

Many file formats and database drivers cannot store infinity. Replace it with a finite sentinel before export if the destination needs a real number.

Is Number.PositiveInfinity available in both Excel and Power BI?

Yes. Both use the same Power Query M engine, so the function behaves the same in each, though menu labels can vary by version.