How to Subtract Positive and Negative Values in Power Query
Question details
The user needs to learn how to correctly calculate the mathematical difference between two amount columns in Power Query when the numbers contain a mix of positive and negative signs.

- Product
- Power Query
- Device & OS
- not provided
- Scenario
- Calculating differences across multiple numerical columns where positive, negative, or mixed sign combinations complicate the mathematical logic.
- Observed behavior
- The goal state is to establish the correct logic (whether straightforward subtraction or comparing absolute values) to yield accurate differences for every possible sign combination.
Before you begin, clearly define the business rule for your calculation to determine whether you need a straightforward mathematical difference or a difference based on absolute values.
Calculate a Straightforward Signed Difference
Use this method when you need a simple mathematical subtraction between two columns, respecting standard algebraic rules.
In a straightforward mathematical subtraction, subtracting a negative number is equivalent to adding its absolute value. For instance, 10 minus -5 equals 15. This is the default behavior when subtracting standard numeric columns in Power Query.
In the Power Query Editor, navigate to the 'Add Column' tab on the ribbon and click on 'Custom Column'.
Name your new column (e.g., 'Difference'). In the Custom column formula box, enter the formula: [Amount2] - [Amount1].
Click 'OK' to create the column. Change the data type of the new column to 'Decimal Number' or 'Currency' by clicking the icon in the column header.

Calculate Difference Using Absolute Values
Use this approach if your business logic requires comparing the magnitude of values while retaining the sign of a specific column.
Calculate and Analyze Data Easily with WPS Office
While Power Query is a specific Microsoft Excel feature, WPS Office provides a highly compatible, lightweight, and free alternative for all your spreadsheet data analysis needs. You can easily calculate absolute and signed differences using standard spreadsheet functions.

Frequently Asked Questions
What happens if I subtract a negative number from a positive number in Power Query?
Mathematically, subtracting a negative number is equivalent to adding its absolute value. For example, [Amount2] - [Amount1] where Amount2 is 5 and Amount1 is -3 will calculate as 5 - (-3), resulting in 8.
How do I handle null or empty values when subtracting columns?
If a column contains null values, a standard subtraction operation will result in a null value. To prevent this, replace nulls with zeros before subtracting by right-clicking the column header, selecting 'Replace Values', and changing 'null' to '0'.
Can I use Excel formulas like ABS and SIGN directly in Power Query?
No, Power Query uses the M language, which operates differently from standard Excel formulas. Instead of Excel's ABS() and SIGN(), you must use Power Query's native functions: Number.Abs() and Number.Sign().
Why is my custom column formula returning an error?
The most common cause for arithmetic errors in Power Query is mismatched or incorrect data types. Ensure that the columns you are attempting to subtract are explicitly formatted as 'Whole Number', 'Decimal Number', or 'Currency', rather than 'Text' or 'Any'.




