Power Query Number.Sign Function: How to Use It
In this article
The Number.Sign function in Power Query returns -1, 0, or 1 based on whether a number is negative, zero, or positive. It’s useful for categorizing values in data analysis without writing custom conditional logic. No special setup is required beyond having Power Query available in Excel, Power BI, or other supported platforms.
What You'll Need
- Microsoft Excel 2016 or later, or Power BI Desktop
- A table or query with numeric columns to evaluate
- Basic familiarity with Power Query Editor (accessed via Data > Get & Transform in Excel or Transform Data in Power BI)
Step-by-Step
- Open your data source in Power Query Editor. In Excel, go to the Data tab and select From Table/Range. In Power BI, select Transform Data from the Home tab.
- Identify the numeric column you want to analyze. This could be sales figures, temperatures, balances, or any value with positive, negative, or zero entries.
- Click on the column header to select the entire column. Make sure it’s set to a numeric data type (Whole Number, Decimal Number, or Currency). If it’s text, convert it first using Transform > Data Type > Whole Number or Decimal Number.
- Go to the Add Column tab in the ribbon.
- Click on Custom Column. A dialog box will appear.
- In the Custom Column dialog, type a name for the new column, such as "SignValue".
- In the formula box, enter:
Number.Sign([YourColumnName]). Replace "YourColumnName" with the exact name of your selected column. For example, if your column is called "Profit", enterNumber.Sign([Profit]). - Click OK. Power Query will generate a new column with -1 for negative numbers, 0 for zero, and 1 for positive numbers.
- Review the results. Scroll through the new column to ensure values are correctly categorized. Look for unexpected results, such as 0 where you expected 1 — this may indicate hidden zeros or formatting errors.
- Click Close & Load to return the updated table to Excel or Power BI. The new column will be included in your data model or worksheet.
Common Mistakes
- Using the function on non-numeric columns: If your column contains text, dates, or null values, Number.Sign will return an error. Always validate the data type before applying the function.
- Typing the column name incorrectly: Power Query is case-sensitive and requires exact column names. If you type
Number.Sign([profit])but the column is named "Profit", you’ll get a "Column not found" error. - Assuming it works on text representations of numbers: "-5" as text won’t work. Convert to number first using
Number.From([TextColumn])before applying Number.Sign. - Forgetting to handle nulls: If your column contains null values, Number.Sign will return null. Use
if [YourColumn] = null then null else Number.Sign([YourColumn])if you want to preserve nulls, or replace them first with 0 using Transform > Replace Values. - Expecting decimal precision to affect the result: Number.Sign ignores magnitude. Both -0.0001 and -1000 return -1. Don’t confuse it with absolute value functions.
Tips
- Combine Number.Sign with conditional formatting in Excel to color-code rows based on sign — green for positive, red for negative, gray for zero.
- Use it in conjunction with Group By to count how many positive, negative, or zero entries exist in a dataset. Add a custom column with Number.Sign, then use Group By to count rows by SignValue.
- For dashboards, create a measure in Power BI using DAX that references the Sign column to show the percentage of positive entries:
% Positive = DIVIDE(COUNTROWS(FILTER('Table', 'Table'[SignValue] = 1)), COUNTROWS('Table')). - Use it to detect anomalies: if a column expected to be all positive suddenly shows -1 values, it may indicate data entry errors or system glitches.
- Apply Number.Sign early in your query pipeline — before complex transformations — to avoid carrying unnecessary numeric precision through multiple steps.
- Test with a small sample first. Create a dummy table with values like 5, -3, 0, 0.5, -100, and null to verify the function behaves as expected before applying it to large datasets.
Troubleshooting
- Error: "We cannot apply operator > to types Text and Number" — This means your column is still text. Select the column, go to Transform > Data Type, and choose Whole Number or Decimal Number. Retry the Number.Sign step.
- Result shows "null" for all rows — Your source column likely contains only null values. Check your source data for missing entries or failed imports. Use Remove Rows > Remove Blank Rows before applying Number.Sign.
- Function returns 1 for negative numbers — Double-check your column name in the formula. A typo like
Number.Sign([Profit])when the column is called "Profits" will cause the function to treat it as null, which may appear as 1 if a default value was applied elsewhere. - Column disappears after applying function — You may have accidentally replaced the original column instead of adding a new one. Always use Add Column > Custom Column, not Transform > Transform Column.
- Power Query crashes when applying function — This often happens with very large datasets. Try filtering the data to a smaller subset first (e.g., keep only 1000 rows), apply the function, then merge back. Also ensure your system has enough RAM and Power Query is updated.
- Function works in Power BI but not in Excel — Ensure both are using the same version of Power Query. Update Excel via File > Account > Update Options > Update Now. Power BI is updated more frequently.
Frequently Asked Questions
Can Number.Sign handle decimal numbers like -2.5?
Yes. Number.Sign works with any numeric type — integers, decimals, and currency values. -2.5 returns -1, 0.001 returns 1.Does it work with blank or null values?
No. If the input is null, Number.Sign returns null. Preprocess with Replace Values or Remove Rows to handle blanks before applying the function.Can I use Number.Sign in a calculated column in Power BI DAX?
No. Number.Sign is a Power Query M function, not a DAX function. In DAX, useSIGN([Column]) instead.
Why does 0 return 0 but -0 return 1?
In most systems, -0 is treated as 0. Power Query follows this standard — there is no distinction between -0 and 0. Both return 0.Is Number.Sign available in Excel Online?
Yes, if you’re using Excel for the web with Power Query enabled. The function behaves identically to the desktop version.Can I chain Number.Sign with other functions like ABS or ROUND?
Yes. For example:Number.Sign(Number.Round([Value], 2)) rounds the value first, then determines its sign. This is useful when dealing with floating-point precision errors.