Smart Systems for Home

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

Power Query Number.RoundTowardZero Function Guide

· 5 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.RoundTowardZero function in Power Query rounds a number toward zero, truncating any decimal places without rounding up or down. It’s useful when you need to discard fractional parts cleanly—such as for inventory counts, age calculations, or grading systems—without mathematical rounding bias. No special setup is required beyond having a numeric column or value in Power Query.

What You'll Need

  • Power Query Editor open in Excel or Power BI Desktop
  • A table with at least one numeric column (integer or decimal)
  • Basic familiarity with adding custom columns or editing formulas in Power Query

Step-by-Step

  1. Open your data source (e.g., Excel workbook or Power BI file) and load the table into Power Query. In Excel, go to Data > Get Data > From Other Sources > From Microsoft Query (or use Power Query Editor directly if already open). In Power BI, click Transform Data on the Home tab.
  2. Locate the table containing the numeric values you want to round. Click the dropdown arrow on the column header to open the column menu.
  3. Select Transform > Round > Round Toward Zero from the column menu. This applies the function directly to the entire column and replaces the original values with their truncated versions. Alternatively, to retain the original column, right-click the column header and choose Duplicate Column first, then apply the rounding to the duplicate.
  4. If you prefer to build the formula manually (e.g., to combine with other logic), click Add Column > Custom Column. In the dialog box, enter a name (e.g., "RoundedValue"), then in the Custom column formula box type: Number.RoundTowardZero([YourColumnName]), replacing "YourColumnName" with the actual column name (including brackets). Click OK.
  5. Verify the result. For example, if a cell contains 4.9, it becomes 4; if it contains -2.3, it becomes -2. Note the function always moves toward zero—positive decimals drop the fraction, negative decimals increase toward zero (e.g., -5.8 → -5).
  6. To apply conditional logic, wrap the function in an if-statement. For instance, to round only positive numbers: if [Value] > 0 then Number.RoundTowardZero([Value]) else [Value]. Click OK to confirm.
  7. Click Close & Load to save and return the updated table to Excel or Power BI. In Excel, the data appears in a new worksheet or table; in Power BI, it loads into the model for report use.

Common Mistakes

  • Confusing with standard rounding: Number.RoundTowardZero does not follow rounding rules (e.g., 2.5 does not become 3). If you expect that behavior, use Number.Round instead.
  • Applying to non-numeric data: If the column contains text (e.g., "12.5" instead of 12.5), the function returns an error. Ensure the column is set to Decimal or Whole Number type using the column type dropdown (top-left of the column header).
  • Overlooking negative numbers: Users sometimes assume "round toward zero" means absolute truncation, but for negatives it increases the value (e.g., -3.7 → -3). Double-check expected behavior for negative inputs.
  • Missing decimal precision: If your data has more decimal places than expected (e.g., floating-point artifacts like 1.999999999), apply Number.RoundTowardZero after rounding to a fixed precision first: Number.RoundTowardZero(Number.Round([Value], 2)).
  • Using in calculated columns incorrectly: In Power BI, if you use this in DAX (not Power Query), the function doesn’t exist—DAX uses INT or TRUNC. This function is strictly for Power Query M language.

Tips

  • Combine with Number.Round: For controlled truncation, round to a specific decimal place first, then truncate: Number.RoundTowardZero(Number.Round([Sales], 1)) ensures you truncate the tenths place cleanly.
  • Use in conditional logic: Handle outliers by rounding only values above a threshold: if [Score] >= 0 then Number.RoundTowardZero([Score]) else null.
  • Preserve original data: Always duplicate the column before applying rounding if you might need the precise values later—right-click the column > Duplicate.
  • Check for nulls: If the column has blank cells, wrap the function in an if-null check: if [Value] = null then null else Number.RoundTowardZero([Value]) to avoid errors.
  • Test with edge cases: Try inputs like 0.5, -0.5, 999.999, and -999.999 to confirm behavior before applying to your full dataset.

Troubleshooting

If Number.RoundTowardZero doesn’t work as expected, follow these checks:

  1. Column type mismatch: Right-click the column header > Data Type > ensure it’s set to Decimal Number or Whole Number. If it’s Text, convert first: right-click > Transform > Format > Convert to Number, or use Number.From([Column]) inside the function.
  2. Formula syntax error: If using a custom column, verify brackets and commas. M language is case-sensitive and strict—use [ColumnName] (not "ColumnName") and match the exact column name (including spaces—wrap in #"Name" if needed).
  3. Unexpected negative behavior: If -4.2 becomes -4 (not -5), this is correct—confirm your expectations align with "toward zero" logic. Use Number.RoundDown or Number.RoundUp for different behavior.
  4. Blank results or errors: Check for non-numeric values (e.g., text like "N/A", empty strings). Filter them out first: right-click column > Filter > Filter Out Blanks, or use Table.SelectRows to exclude non-numbers.
  5. Formula not updating: After editing a custom column formula, click the checkmark to apply changes (not just close the dialog). If using the column menu’s Round Toward Zero, re-select it—it may not auto-refresh after data changes.
  6. Power BI vs. Excel differences: In Power BI Desktop, ensure you’re editing in Power Query (Transform Data), not the report view. The function works identically in both platforms, but menu paths differ slightly.

Frequently Asked Questions

What’s the difference between Number.RoundTowardZero and Number.RoundDown?

Number.RoundTowardZero always moves toward zero (e.g., -3.2 → -3), while Number.RoundDown always rounds to the next lower integer (e.g., -3.2 → -4). For positive numbers, both behave the same.

Does Number.RoundTowardZero work with null or blank values?

No—it throws an error if the input is null. Always wrap it in a null check: if [Value] = null then null else Number.RoundTowardZero([Value]).

Can I round to a specific decimal place (e.g., 2 decimals) before truncating?

Yes. Chain functions: Number.RoundTowardZero(Number.Round([Value], 2)) first rounds to two decimals, then truncates any further digits (e.g., 3.149 → 3.14 → 3.14).

Why does -2.9 become -2 instead of -3?

Because "toward zero" means increasing negative numbers (less negative). -2.9 is closer to -3, but moving toward zero means going from -2.9 to -2 (since -2 > -2.9 on the number line).

Is this function available in Power BI DAX or only in Power Query?

Only in Power Query (M language).

Does Number.RoundTowardZero handle very large numbers or scientific notation?

Yes—it works with any numeric value Excel or Power BI can store, including values in scientific notation (e.g., 1.23E+05 becomes 123000). Ensure the column type is set to Decimal to avoid precision loss.