<!-- https://learnsql.cpetoday.com/functions/m/number-mod -->
# Number.Mod

Language: Power Query M
Category: Number
Syntax: Number.Mod(number as nullable number, divisor as number, optional precision as any) as nullable number
Summary: Returns the remainder left after dividing one number by another.
Returns: The remainder, or null when the input is null.
Level: Intermediate
Related: Number.IntegerDivide, Number.Round, Number.RoundDown, Number.Sign, Number.Abs

## 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
- number: the value to divide.
- divisor: the number to divide by.
- precision (optional): a setting for the arithmetic used. Leave it out for whole numbers.
## 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.

```powerquery
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
- The result is the remainder, not the quotient. Use Number.IntegerDivide for the whole number of divisions.
- With a negative number the sign of the remainder can surprise. Test a negative value before you use the result.
- A divisor of zero gives an error, so guard against it.
- Null in gives null out.
## 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.
