The Number.Abs function in Power Query gives you the absolute value of a number, which is the number without its minus sign. So -250 becomes 250, and 250 stays 250.
This article shows how to use it to turn negative numbers positive, find the gap between two numbers, filter and sort by the size of a change, and more.
Follow along with the example file
Number.Abs Function Examples.xlsx
Number.Abs Function Syntax
Number.Abs(number as nullable number) as nullable number
- number – the number you want the absolute value of.
What it returns: The number without its sign, so it’s always zero or positive. If the number is null, it returns null.
The Number.Abs function is part of the Power Query M language, so it works wherever Power Query does in Excel: Excel 365, 2024, 2021, 2019, and 2016 for Windows, and Excel for Microsoft 365 on Mac.
When to Use the Number.Abs Function
Use this function when you need to:
- Convert negative numbers to positive in a column
- Find how far apart two numbers are, no matter which one is bigger
- Keep only the rows where a difference is more than an allowed limit
- Sort changes by their size, so the biggest ups and downs come first
- Add up movement in both directions instead of the net total
- Split one signed amount column into separate Debit and Credit columns
Example 1: Get the Absolute Value of a Number
Let’s start with the basic idea. Suppose a refund of 250 shows up in your data as -250, and you just want the amount without the minus sign.
In Excel, go to Data > Get Data > From Other Sources > Blank Query. In the Power Query Editor that opens, type this formula in the formula bar:
= Number.Abs(-250)
Result: 250

Here, Number.Abs drops the minus sign and returns 250. If you give it a positive number, like 250, you get the same 250 back.
In the example file, Example 1 types its number right into the query, so it doesn’t have a sheet. You can open it from Data > Queries & Connections.
Example 2: Convert Negative Numbers to Positive in a Column
Here’s the most common use. Below is a table named CardCharges with card transactions, where the charges come in as negative numbers, and I want the Amount column to show every amount as a positive number.

In the code below, the Source line uses the Excel.CurrentWorkbook function to pull the CardCharges table into Power Query by its name.
If you try this on your own data, format it as a table (Ctrl + T) and put your table’s name in place of “CardCharges”.
Create a new blank query (as in Example 1), open the Advanced Editor (Home > Advanced Editor), and use this code:
let
Source = Excel.CurrentWorkbook(){[Name="CardCharges"]}[Content],
#"Converted to Positive" = Table.TransformColumns(Source,{{"Amount",Number.Abs,type number}})
in
#"Converted to Positive"
Result: The Amount column shows 45.5, 120, 18.75, 32, 64.2, and null

Here, the Table.TransformColumns function runs Number.Abs on every value in the Amount column and changes it in place, so you don’t get an extra column.
The negative charges, like -45.5, become positive. The Amazon Refund was already positive (32), so it stays 32.
So when you want every amount positive, Number.Abs works better than multiplying the column by -1. Multiplying would turn the refund into -32, while Number.Abs only changes the numbers that are negative.
The catch is that the refund now looks just like a charge, so a total of this column would count it as spending.
If you plan to total the column as spending, multiply by -1 instead. The charges then become positive and the refund turns into -32, so it reduces the total.
The Spotify row has a blank amount, which Power Query reads as null. Number.Abs returns null for it instead of an error, so one blank cell doesn’t break the query.
Important: Number.Abs needs real numbers. If the column holds text, like “-45”, you get the error We cannot convert the value “-45” to type Number, so change the column type to a number first.
Example 3: Find the Absolute Difference Between Two Numbers
This next one comes up a lot in reports. Below is a table named BudgetReview with each department’s budget and actual spend, and I want a Difference column that shows how far off each department was, whether it went over or under.

Create a new blank query, open the Advanced Editor, and use this code:
let
Source = Excel.CurrentWorkbook(){[Name="BudgetReview"]}[Content],
#"Added Difference" = Table.AddColumn(Source,"Difference",each Number.Abs([Actual]-[Budget]),type number)
in
#"Added Difference"
Result: A new Difference column (3800, 6500, 0, 7250, and 6300)

Here, the Table.AddColumn function adds a Difference column. For each row, it subtracts the budget from the actual spend, and Number.Abs removes the sign from the result.
Marketing spent 46200 against a budget of 50000, so Actual minus Budget is -3800. Number.Abs turns that into 3800, the same way IT’s overspend of 6500 stays 6500.
So you get the size of the miss in both cases. If you also need to know the direction, keep a separate column with the plain [Actual]-[Budget] result.
Example 4: Keep Rows Where the Difference Is More Than a Limit
Number.Abs is also handy for filtering. Below is a table named StockCount with the system quantity and the counted quantity of each item, and I want to keep only the items where the two are off by more than 2 units, either way.

Create a new blank query, open the Advanced Editor, and use this code:
let
Source = Excel.CurrentWorkbook(){[Name="StockCount"]}[Content],
#"Kept Mismatches" = Table.SelectRows(Source,each Number.Abs([Counted Qty]-[System Qty])>2)
in
#"Kept Mismatches"
Result: A table with three rows: A-102 Toner Cartridges, A-104 Envelopes, and A-106 File Folders

Here, the Table.SelectRows function keeps the rows where the gap between the counted and system quantity is more than 2.
Envelopes were counted 7 over the system number, and Toner Cartridges were 5 short. Both have a gap of more than 2 once Number.Abs removes the sign, so both stay.
Without Number.Abs, a test like [Counted Qty]-[System Qty]>2 would only catch the overcounts. The shortages give negative numbers, so they’d never pass the test.
Printer Paper is 2 short, which isn’t more than 2, so it’s left out. Use >=2 instead if a gap of exactly 2 should count too.
Follow along with the example file
Number.Abs Function Examples.xlsx
Example 5: Sort by the Size of a Change
This next one is about sorting. Below is a table named SalesChange with how much each sales rep’s sales went up or down this month, and I want to sort it so the biggest changes come first, whether they’re gains or drops.

Create a new blank query, open the Advanced Editor, and use this code:
let
Source = Excel.CurrentWorkbook(){[Name="SalesChange"]}[Content],
#"Sorted by Size" = Table.Sort(Source,{{each Number.Abs([Sales Change]),Order.Descending}})
in
#"Sorted by Size"
Result: The table sorted as Carrie (-3400), Elizabeth (2600), Tyler (-1900), Laura (1200), Bruce (850), and Scott (-150)

Here, the Table.Sort function sorts the rows by Number.Abs([Sales Change]) instead of by the Sales Change column itself. So Carrie’s drop of 3400 counts as a change of size 3400 and goes to the top.
The Sales Change column still shows the real values with their signs, because Number.Abs is only used to decide the order. You don’t need a helper column for it.
A normal descending sort on the Sales Change column would put Elizabeth’s 2600 first and Carrie’s -3400 last, which hides the biggest change at the bottom.
Example 6: Get the Net Change and the Total Movement
Now let’s add numbers up both ways. Below is a table named StockAdjustments with stock coming in (positive units) and going out (negative units), and I want both the net change and the total number of units that moved.

Create a new blank query, open the Advanced Editor, and use this code:
let
Source = Excel.CurrentWorkbook(){[Name="StockAdjustments"]}[Content],
Summary = [Net Change = List.Sum(Source[Units]),Total Movement = List.Sum(List.Transform(Source[Units],Number.Abs))]
in
Summary
Result: A record with Net Change -25 and Total Movement 175

Here, the outer square brackets with name = value pairs build a record, which is a single set of named values. The preview shows it as two fields, Net Change and Total Movement, each next to its value.
Inside it, Source[Units] gets the Units column as a list. The List.Sum function adds it up as is, so the ins and outs cancel each other, and the net change is -25.
For the Total Movement, the List.Transform function first runs Number.Abs on every value, so -60 becomes 60. List.Sum then adds those, and you get 175 units moved in total.
The two numbers answer different questions. The net change tells you the stock went down by 25 units, while the total movement tells you how busy the stock room was.
Example 7: Split an Amount Column into Debit and Credit Columns
This one is great for bank data. Below is a table named BankStatement with one Amount column, where money going out is negative, and I want separate Debit and Credit columns that both show positive amounts.

Create a new blank query, open the Advanced Editor, and use this code:
let
Source = Excel.CurrentWorkbook(){[Name="BankStatement"]}[Content],
#"Added Debit" = Table.AddColumn(Source,"Debit",each if [Amount]<0 then Number.Abs([Amount]) else null,type number),
#"Added Credit" = Table.AddColumn(#"Added Debit","Credit",each if [Amount]>0 then [Amount] else null,type number)
in
#"Added Credit"
Result: A Debit column (null, 1450, 96.4, null, and 132.15) and a Credit column (3200, null, null, 780, and null)

Here, the first step adds a Debit column. If the amount is negative, Number.Abs turns it into a positive number, so the Rent Payment of -1450 shows as 1450, and any other row gets an empty cell (null).
The second step adds a Credit column the same way for the positive amounts. These are already positive, so they don’t need Number.Abs.
When you load this to Excel, the null cells show up as blanks, which is how most statements and ledgers show debits and credits.
Example 8: Find How Many Days Early or Late Each Delivery Was
The last one works with dates. Below is a table named Deliveries with the promised and actual delivery dates for each order, and I want a Days Early or Late column that shows how many days each delivery was off schedule, early or late.

Create a new blank query, open the Advanced Editor, and use this code:
let
Source = Excel.CurrentWorkbook(){[Name="Deliveries"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Promised Date",type date},{"Delivered Date",type date}}),
#"Added Days Early or Late" = Table.AddColumn(#"Changed Type","Days Early or Late",each Number.Abs(Duration.Days([Delivered Date]-[Promised Date])),Int64.Type)
in
#"Added Days Early or Late"
Result: A new Days Early or Late column (3, 2, 0, 7, and 4)

Here, the Changed Type step sets both columns to the date type. Subtracting one date from the other then gives a duration, like 3 days, or -2 days when the order arrived early.
The Duration.Days function turns that duration into a plain number of days, and Number.Abs drops the minus sign. So PO-8802, which came 2 days early, shows 2.
The new column only shows the size of the gap, so a 2 can mean early or late. If you need the direction too, add another column with the plain Duration.Days([Delivered Date]-[Promised Date]) result, where early deliveries show as negative numbers.
Important: Number.Abs only works on numbers. If you give it the duration directly, like Number.Abs([Delivered Date]-[Promised Date]), you get an error like We cannot convert the value #duration(3, 0, 0, 0) to type Number, so convert the duration with Duration.Days first.
Other Excel Articles You May Also Like:
- Record.FieldValues
- Number.RoundDown
- Number.Mod – Use Number.Mod in Power Query M to get the remainder of a division.
- Number.Round – Use Number.Round in Power Query M to round numbers.
- Number.RoundUp – Use Number.RoundUp in Power Query M to round numbers up.
- Number.IntegerDivide – Use Number.IntegerDivide in Power Query M to divide and drop the remainder.
- Number.From – Use Number.From in Power Query M to convert values to numbers.
- List.Sum – Use List.Sum in Power Query M to add up a list of numbers.