Power Query Number.NegativeInfinity Function
In this article
Number.NegativeInfinity is a Power Query M constant that returns the special numeric value representing negative infinity. You do not call it with parentheses or arguments: you write it as a bare identifier in your M expression, and it returns a value that is smaller than any finite number. It is useful when you need a guaranteed lower bound in comparisons, a starting value for a running minimum, or a placeholder that should never win a "largest value" comparison. Nothing needs to be installed or enabled beyond Power Query itself, which is built into Excel, Power BI Desktop, and Dataflows.
What You'll Need
- Excel (Power Query is on the Data tab under Get & Transform Data) or Power BI Desktop, or access to a Power Query dataflow.
- A query you can edit in the Power Query Editor, or a blank query to experiment in.
- Basic familiarity with the M formula language, specifically how to open the Advanced Editor or the formula bar.
Step-by-Step
- Open your workbook or report and launch the Power Query Editor. In Excel, go to Data > Get & Transform Data > Launch Power Query Editor. In Power BI Desktop, use Home > Transform data. Menu labels can differ slightly by version and platform.
- Create a blank query to test with: in the editor, choose Home > New Source > Other Sources > Blank Query. A blank query opens with a default expression of
= ...that you can replace. - Open the formula bar (View > Formula Bar if it is hidden) or the Advanced Editor (Home > Advanced Editor). The formula bar is easier for a single expression; the Advanced Editor is better when you are editing a full let block.
- Type the constant exactly as
Number.NegativeInfinity. Do not add parentheses. M is case-sensitive, so the capital N in Number and the capital I in Infinity matter. - Confirm the result. The query should evaluate to a value displayed as
-∞(negative infinity). If you see an error instead, re-check the spelling and casing. - Use it inside a comparison. For example, to start a running minimum, write something like
List.Accumulate(MyList, Number.NegativeInfinity, (state, current) => if current > state then current else state)when you want a maximum-style accumulator seeded below every possible value. Swap the comparison for a minimum seed ofNumber.PositiveInfinity. - Use it as a safe lower bound. If you are filtering rows with
Table.SelectRows, a condition such as[Value] > Number.NegativeInfinityis true for every finite number, which lets you build a parameterised threshold where the "no limit" case is represented cleanly. - Test the edge cases in a blank query. Compare
Number.NegativeInfinity < -1E308(true) andNumber.NegativeInfinity = Number.NegativeInfinity(true). This confirms you are working with the special value rather than a very small ordinary number. - Handle it before loading. If the column containing infinity will be loaded to a worksheet or a visual, wrap it with a replacement step so consumers do not see an unhelpful symbol. For example, add a conditional column or use
Table.ReplaceValueto swap the value for a blank or a chosen sentinel number. - Apply your changes with Home > Close & Load (Excel) or Home > Close & Apply (Power BI Desktop). Save the file so the query definition persists.
Common Mistakes
- Adding parentheses.
Number.NegativeInfinity()is not valid because it is a constant, not a function. Write it without brackets. - Wrong casing.
number.negativeinfinityorNumber.NegativeInfinitywith a stray space will fail. M identifiers are case-sensitive. - Expecting a very large negative number. It is not
-1E308or any finite value. Arithmetic with it behaves specially: adding a finite number to it still returns negative infinity. - Assuming it survives export cleanly. Many destinations cannot represent infinity. Convert or replace it before loading.
- Confusing it with null. Null means "no value"; negative infinity is a real numeric value that compares lower than every finite number. Comparisons involving null propagate null, not true or false.
- Using it where a type is enforced. If a step declares a column as a specific numeric type, an infinity value can trigger a conversion error. Check the Changed Type step.
Tips
- Use
Number.PositiveInfinityas the mirror constant for seeding a minimum. - Keep a small scratch query with test comparisons so you can confirm behaviour before wiring the constant into a real transformation.
- If you need to detect infinity values in a column, compare against the constant rather than looking for a text symbol, since the display form depends on where you view it.
- Document the seed value in a comment inside the Advanced Editor so the next person understands why an unusual constant appears in the logic.
- Prefer explicit replacement steps near the end of the query so the infinity value is available for calculations but never reaches the output.
Troubleshooting
If the expression shows an error, first check spelling and casing, then confirm you did not add parentheses. If the query evaluates but a later step fails, look at the step immediately after the one that introduces the constant; type conversion is the usual culprit. If the value displays as text or a symbol you did not expect, that is a display issue in the preview, not a change in the underlying value.
If loading fails, add a replacement step before Close & Load so infinity becomes blank or a finite sentinel. If calculations return unexpected results, remember that arithmetic involving infinity follows special rules and that comparisons with null return null. If the whole query will not refresh, remove the constant temporarily to isolate whether it is the cause, then reintroduce it one step at a time. Restarting the application and updating to the current version resolves some editor quirks, and the Advanced Editor is the most reliable place to inspect the exact expression.
Frequently Asked Questions
Is Number.NegativeInfinity a function?
No. It is a constant value in the M language. You reference it by name without parentheses or arguments.
What is the difference between it and null?
Null represents the absence of a value. Negative infinity is a numeric value that is lower than every finite number. They behave differently in comparisons and arithmetic.
Can I load it into an Excel worksheet?
It is generally better to replace it first. Many output destinations cannot represent infinity, so convert it to blank or a chosen number before loading.
Does it work in both Excel and Power BI?
Yes. Both use the same Power Query engine and the same M language, so the constant behaves identically in each.
How do I check whether a value is infinite?
Compare it directly with the constant, or use the related number functions in M that test for infinity. Comparing against the constant is the most explicit approach.
Why does arithmetic with it give odd results?
Infinity follows special arithmetic rules. Adding or subtracting finite numbers leaves it infinite, and some operations produce errors or null. Handle it before doing mixed calculations.