Smart Systems for Home

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

Power Query Number.Abs: Absolute Value Made Easy

· 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.Abs function in Power Query returns the absolute value of a number — that is, the number without its sign. If you have a column of positive and negative values and you need all positives (for example, to compare magnitudes or clean up variances), Number.Abs converts -5 to 5 and leaves 5 as 5. You can use it in a custom column, in a transformation step, or directly in the formula bar. No special setup is required beyond having Power Query available in Excel, Power BI, or another Microsoft tool that hosts it.

What You'll Need

  • Access to Power Query — in Excel via Data > Get & Transform Data, or in Power BI Desktop via Transform Data.
  • A table or query loaded into the Power Query Editor that contains at least one numeric column.
  • Basic familiarity with adding a custom column or editing the formula bar. Labels and menu locations can differ slightly by version, device, or region.

Step-by-Step

  1. Open the Power Query Editor. In Excel, select your data and choose Data > From Table/Range. In Power BI Desktop, click Transform Data to open the editor.
  2. Locate the query and the numeric column you want to transform. If the column contains negative numbers, you will see them with a minus sign.
  3. Add a custom column. Go to the Add Column tab and click Custom Column. (In some versions the button may be labeled Custom Column or Add Custom Column.)
  4. In the Custom Column dialog, give the new column a name, such as "Absolute Value".
  5. In the formula box, type the function call. For a column named "Amount", enter:
    Number.Abs([Amount])
    Replace [Amount] with the exact name of your column, including brackets. Column names are case-sensitive in Power Query, so match the case exactly.
  6. Click OK. Power Query adds a new step and shows the new column with all values converted to positive numbers. Null values remain null.
  7. If you prefer to transform the original column in place, you can instead use the formula bar. Select the column, then in the formula bar replace the existing step expression with one that wraps the column reference in Number.Abs. For example, change = Table.TransformColumnTypes(...) or the relevant step to use Number.Abs. This is more advanced; using a custom column is safer and easier to undo.
  8. Check the result. Scroll through the new column to confirm that negative values are now positive and positive values are unchanged. Also verify that nulls and errors are handled as expected.
  9. Close and load. When satisfied, click Close & Load (or Close & Load To) to send the transformed data to a worksheet or data model.

Common Mistakes

  • Forgetting brackets around the column name. Power Query expects [ColumnName], not just ColumnName. Without brackets, you will get an error.
  • Using the wrong case. Column names are case-sensitive. If your column is "Amount" but you type [amount], the step will fail.
  • Assuming Number.Abs changes the original column. A custom column adds a new column; the original remains unchanged. If you need to replace the original, you must remove or rename columns afterward.
  • Expecting Number.Abs to handle text. If the column contains text values like "-5" (as text), Number.Abs will return an error. Convert the column to a number type first, or use Number.FromText before applying Number.Abs.
  • Ignoring nulls. Number.Abs returns null for null input. If you need zeros instead, wrap the expression in a coalesce, such as Number.Abs([Amount] ?? 0).

Tips

  • You can apply Number.Abs to multiple columns at once by creating several custom columns or by using a single custom column with a record or list, but the simplest approach is one custom column per numeric column.
  • Use the formula bar to inspect the generated step. It will show something like = Table.AddColumn(#"Previous Step", "Absolute Value", each Number.Abs([Amount])). This helps you learn M code and troubleshoot.
  • If you need the absolute value only for a calculation (not a new column), you can use Number.Abs inside another expression, such as in a custom column that computes a difference: Number.Abs([Value1] - [Value2]).
  • Remember that Number.Abs works on numbers, not on durations or other types. For durations, use Duration.Abs if available, or convert to a number first.
  • When working with large datasets, adding a custom column is generally efficient, but you can also use the Transform tab's Number Column > Absolute Value option if it exists in your version. That command applies the transformation in place without adding a new column.

Troubleshooting

If Number.Abs does not work as expected, check these common issues:

  • Error: "The name 'Number.Abs' wasn't recognized." This usually means a typo or that you are using a version of Power Query that does not support the function. Number.Abs is a standard function in Power Query for Excel and Power BI, so check spelling and ensure you are in the Power Query Editor, not a regular Excel formula.
  • Error: "We couldn't convert to Number." The column contains non-numeric values. Change the column data type to a numeric type (Whole Number, Decimal Number, or Currency) before applying Number.Abs. If the column has text that looks like numbers, use Transform > Data Type > Using Locale or Number.FromText to convert.
  • The new column shows errors for some rows. Inspect those rows. They may contain nulls, text, or values that cannot be converted. Filter or clean the data first.
  • The step does not appear in the Applied Steps list. If you edited the formula bar directly, the step may have been overwritten. Use the Applied Steps list to review each step and ensure your change is included.
  • Performance is slow. If you have many custom columns, consider combining transformations or using the built-in Absolute Value command under Transform > Number Column, which may be more efficient.

If you are unsure whether a step exists in your version, refer to the official Microsoft documentation for Power Query functions.

Frequently Asked Questions

What does Number.Abs do in Power Query?

It returns the absolute value of a number, removing any negative sign. For example, Number.Abs(-3) returns 3, and Number.Abs(3) returns 3.

Can I use Number.Abs on a column with null values?

Yes, but nulls remain null. If you want nulls to become zero, use the coalesce operator (??) as shown in the tips.

Is there a built-in button for absolute value in Power Query?

Some versions include a Transform > Number Column > Absolute Value command. If you do not see it, use a custom column with Number.Abs instead.

Does Number.Abs work on text that looks like a number?

No. The column must be a numeric data type. Convert text to number first using the data type menu or Number.FromText.

Can I apply Number.Abs to multiple columns at once?

Not directly with a single custom column unless you use advanced M code. The simplest method is to create one custom column per numeric column.

What happens if I use Number.Abs on a column with errors?

Errors propagate. The new column will show errors for those rows. Clean or replace errors before applying the function.