Power Query Number.Epsilon: What It Is and How to Use It
In this article
Number.Epsilon is a built-in Power Query constant that returns the smallest positive number that can be represented as a double-precision floating-point value. In practical terms, it gives you a tiny number (approximately 4.9406564584124654E-324) that you can use as a safe lower bound when dividing or comparing values, helping to avoid divide-by-zero errors in calculated columns. You do not need to enable anything special to use it; it is available in any Power Query query in Excel, Power BI, and other Microsoft tools that host Power Query. The steps below show how to call it, where to use it, and how to avoid the common pitfalls.
What You'll Need
- A version of Excel, Power BI Desktop, or another Microsoft product that includes the Power Query Editor (the function is part of the standard M library).
- A query open in the Power Query Editor, or the ability to create a new blank query.
- Basic familiarity with adding a custom column or editing the formula bar.
Step-by-Step
- Open the Power Query Editor. In Excel, go to the Data tab and choose Get Data > Launch Power Query Editor (or edit an existing query). In Power BI Desktop, choose Transform Data from the Home ribbon. Menu labels can differ slightly by version, device, and region.
- Create or select a query. You can use any existing query or start with a blank query: in the Home ribbon, choose New Source > Blank Query (or New Source > Other Sources > Blank Query, depending on your version).
- Open the Advanced Editor or formula bar. For a quick test, select the blank query and open the formula bar (View > Formula Bar if it is not visible). You can also use Home > Advanced Editor to type a full expression.
- Enter the expression. Type
= Number.Epsilonin the formula bar and press Enter. The query will return a single scalar value, the smallest positive double. If you are in the Advanced Editor, the full query would be:let Source = Number.Epsilon in Source - Use it in a calculation. The most common use is to protect a division from a zero denominator. For example, in a custom column formula you might write
[Numerator] / Number.Max([Denominator], Number.Epsilon). This ensures the denominator is never exactly zero, so the division returns a very large number instead of an error. You can also use it in comparisons where you want to treat values below a threshold as effectively zero. - Add a custom column (optional). With your table selected, go to Add Column > Custom Column. In the formula box, enter an expression such as
[Sales] / Number.Max([Units], Number.Epsilon). Give the column a name and click OK. The new column will appear with the protected division applied to every row. - Check the result type. Power Query may infer the result as a number. If you see errors, verify that the columns you are dividing are numeric. You can change the data type using the Transform tab or by clicking the type icon in the column header.
- Load or close & apply. Once the query returns the expected values, load it to a worksheet or data model (Home > Close & Load) or apply changes in Power BI.
Common Mistakes
- Expecting Number.Epsilon to be a normal small number like 0.0001. It is the smallest positive double, roughly 4.94E-324. Using it as a denominator will produce extremely large results, not moderate ones. If you need a practical small value, use a literal like 0.000001 instead.
- Forgetting that Number.Epsilon is a constant, not a function. Writing
Number.Epsilon()with parentheses will cause an error. Use it without parentheses. - Using it in text or logical comparisons without converting types. If you compare a text column to Number.Epsilon, Power Query may return unexpected results or errors. Ensure both sides are numeric.
- Assuming it prevents all division errors. It only prevents division by exactly zero. If the denominator is null, you will still get an error; handle nulls separately with
??ortry otherwise. - Confusing it with Number.POSITIVE_INFINITY or Number.NaN. Those are different constants with different behaviors. Number.Epsilon is strictly the smallest positive value.
Tips
- Use
Number.Max([Denominator], Number.Epsilon)as a guard when you cannot guarantee non-zero denominators. This is safer than a hard-coded small number because it works for any numeric type. - If you need a tolerance for floating-point comparisons, a value like 1E-12 is usually more practical than Number.Epsilon, which is far below the precision of most real-world data.
- You can combine Number.Epsilon with
Number.Absto avoid negative denominators:Number.Max(Number.Abs([Denominator]), Number.Epsilon). - Test your expression on a small sample before applying it to a large table, especially if the result feeds into further calculations.
- Remember that Power Query is case-sensitive for identifiers: use
Number.Epsilonexactly, notnumber.epsilon.
Troubleshooting
If you see an error such as "The name 'Number.Epsilon' wasn't recognized," check that you are using a version of Power Query that includes the constant (it has been part of the M library for many versions, but very old releases may lack it). Update your software if possible. If the expression returns an error about type mismatch, confirm that the column you are dividing is numeric and not text. If the result is unexpectedly large or infinite, your denominator was likely zero and Number.Epsilon made it extremely small, producing a huge quotient; consider using a larger guard value or filtering out zero denominators. If the custom column shows errors only on some rows, inspect those rows for nulls or non-numeric values and handle them with try ... otherwise or by replacing nulls before the division. Finally, if the formula bar does not accept the expression, try using the Advanced Editor to enter the full query, which avoids some formula bar quirks.
Frequently Asked Questions
What is Number.Epsilon in Power Query?
It is a constant that returns the smallest positive double-precision floating-point number, approximately 4.9406564584124654E-324. It is part of the standard M library.
Do I need to import anything to use Number.Epsilon?
No. It is built into Power Query and available in any query without additional imports or references.
Can I use Number.Epsilon to avoid divide-by-zero errors?
Yes, by using it as a lower bound for the denominator, for example [A] / Number.Max([B], Number.Epsilon). However, the result will be extremely large if the denominator was zero, so consider whether a larger guard value suits your data better.
Why does Number.Epsilon() with parentheses fail?
Because Number.Epsilon is a constant, not a function. Use it without parentheses.
Is Number.Epsilon the same as a tolerance for comparing numbers?
No. It is far smaller than typical floating-point tolerances. For comparisons, use a practical tolerance such as 1E-12.
Does Number.Epsilon work in Power BI and Excel alike?
Yes, because both use the same Power Query engine. The exact menu locations may differ, but the expression is identical.