If you want to divide two numbers in Power Query and keep only the whole-number part of the answer, Number.IntegerDivide is the function you reach for. It drops the fractional part and hands back just the integer quotient. In this article, I’ll show you how to use Number.IntegerDivide with a few simple examples.
Syntax of Number.IntegerDivide Function
Number.IntegerDivide(number1 as nullable number, number2 as nullable number, optional precision as nullable number) as nullable number
where
number1(required, nullable number). The number being divided (the dividend).number2(required, nullable number). The number you divide by (the divisor).precision(optional, nullable number). Sets the calculation accuracy using aPrecisionvalue.Precision.Doubleis the default and is fine for everyday inputs.Precision.Decimalswitches to a more exact decimal evaluation, useful when tiny floating-point rounding could otherwise push a result across an integer boundary.
Returns: a number, the whole-number part of number1 / number2 after truncating toward zero. If either number1 or number2 is null, it returns null.
In plain terms, you give it two numbers and it tells you how many whole times the second goes into the first, ignoring any remainder.
Example 1: Divide two numbers and keep the whole part
Divide 17 by 5 and keep only the whole part of the answer.
Number.IntegerDivide(17,5)
Result: 3
17 divided by 5 is 3.4. The function drops the .4 and returns 3.
Example 2: How negative numbers are handled
Now try the same division with a negative numerator.
Number.IntegerDivide(-17,5)
Result: -3
-17 divided by 5 is -3.4. The function truncates toward zero, so it returns -3, not -4.
Example 3: Divide with decimal inputs
The inputs don’t have to be whole numbers. Divide 8.3 by 3.
Number.IntegerDivide(8.3,3)
Result: 2
8.3 divided by 3 is about 2.77. Only the whole part survives, so the result is 2.
Example 4: Convert total minutes to whole hours in a table
A common use is turning a running count into whole units, like total minutes into full hours.
Say you have a Sessions query with a SessionID and a TotalMinutes column.
You want a WholeHours column that shows how many full hours each session ran.
Here is the starting data:
| SessionID | TotalMinutes |
|---|---|
| S-01 | 185 |
| S-02 | 60 |
| S-03 | 59 |
| S-04 | 400 |
Set the TotalMinutes column to a whole-number type with Table.TransformColumnTypes, then add a column that divides it by 60 and keeps the whole part:
let
Source = Excel.CurrentWorkbook(){[Name="Sessions"]}[Content],
Typed = Table.TransformColumnTypes(Source,{{"TotalMinutes", Int64.Type}}),
AddHours = Table.AddColumn(Typed,"WholeHours",each Number.IntegerDivide([TotalMinutes],60),Int64.Type),
Result = Table.SelectColumns(AddHours,{"SessionID","WholeHours"})
in
Result
This gives each session its count of full hours.
The result keeps two columns:
| SessionID | WholeHours |
|---|---|
| S-01 | 3 |
| S-02 | 1 |
| S-03 | 0 |
| S-04 | 6 |
The S-03 row shows 0 because 59 minutes is not a full hour yet, which is what you want when counting whole hours.
Things to keep in mind with Number.IntegerDivide
- It truncates toward zero, it does not floor. A negative quotient like
-3.4becomes-3, not-4. If you need true floor behavior that rounds down to-4, useNumber.RoundDowninstead. - Dividing by zero raises an error. The result has no integer to return, so the query fails. Guard it with
try Number.IntegerDivide([n],[d]) otherwise nullto get anull(orotherwise 0) instead of a broken query. - A
nullinput gives backnull. If either number can be blank, decide what an empty result should mean before it flows into later steps. - It gives you the quotient, not the remainder. For the leftover after the whole division, use
Number.Mod. The two are complements: whole hours fromNumber.IntegerDivide, leftover minutes fromNumber.Mod.
Common questions about Number.IntegerDivide
What is the difference between Number.IntegerDivide and the / operator?
The / operator gives the full decimal answer, like 3.4. Number.IntegerDivide gives only the whole part, like 3.
How is it different from Excel’s QUOTIENT function?
They behave the same way on truncation. Both keep the whole part and truncate toward zero, so Number.IntegerDivide is the Power Query equivalent of Excel’s QUOTIENT.
How do I also get the remainder?
Use Number.Mod alongside it. Number.IntegerDivide(185,60) gives 3 whole hours and Number.Mod(185,60) gives the leftover 5 minutes.
List of All Power Query Functions
Related Power Query Functions / Articles: