Downloads
Power Query MNumberIntermediate

Number.Mod

Returns the remainder left after dividing one number by another.

Syntax
Number.Mod(number as nullable number, divisor as number, optional precision as any) as nullable number

Returns: The remainder, or null when the input is null.

What it does

Number.Mod returns what is left over after a whole number of divisions. A remainder answers questions such as "how many days are left after full weeks" or "is this voucher number an even batch". Finance teams use it for leftover days in a period, for batch boundaries, and for simple control rules such as a check digit that is a remainder of a division.

Syntax and arguments

Example

A rent schedule is billed every seven days, and the team needs to know how many days of the last period are left after full weeks.

let
    DaysInPeriod = 45,
    FullWeeks = Number.IntegerDivide(DaysInPeriod, 7),
    LeftoverDays = Number.Mod(DaysInPeriod, 7)
in
    {FullWeeks, LeftoverDays}

Forty five days is six full weeks plus three days, so the result is {6, 3}. The leftover days are billed as a short period at the end.

Example: a second, different use

Find every 12th row of a batch to sample it for review, using Number.Mod on the row index to pick out the rows whose remainder is zero.

Things to watch

In business terms

Billing cycles, sampling every nth item and check digit rules all depend on remainders. Keeping the remainder logic in the query makes the rule visible to an auditor, instead of a hidden formula in a spreadsheet.

Related functions

All Power Query M functions · View as Markdown · M basics