Number.IntegerDivide Function (Power Query M)

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 a Precision value. Precision.Double is the default and is fine for everyday inputs. Precision.Decimal switches 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:

SessionIDTotalMinutes
S-01185
S-0260
S-0359
S-04400

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:

SessionIDWholeHours
S-013
S-021
S-030
S-046

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.4 becomes -3, not -4. If you need true floor behavior that rounds down to -4, use Number.RoundDown instead.
  • 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 null to get a null (or otherwise 0) instead of a broken query.
  • A null input gives back null. 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 from Number.IntegerDivide, leftover minutes from Number.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:

I am a huge fan of Microsoft Excel and love sharing my knowledge through articles and tutorials. I work as a business analyst and use Microsoft Excel extensively in my daily tasks. My aim is to help you unleash the full potential of Excel and become a data-slaying wizard yourself.