The Power Automate Mod function, also known as the modulo operator, returns the remainder of dividing the dividend by the divisor.
In other words, mod(dividend, divisor) = dividend % divisor. For example, mod(5, 2) would return 1, because 5 divided by 2 is 2 with a remainder of 1.
In this article, I’ll introduce you to the mod function and will provide a step-by-step guide on how to use the function in a Microsoft flow.
Power Automate Mod Function
To find the remainder when dividing two numbers, use the mod function. To obtain the integer quotient, use the div() function.
- dividend (mandatory): The number that will be divided by the divisor.
- divisor (mandatory): The number that will divide the dividend, but must not be zero.
- Returns the remainder after dividing the first number by the second number.
Power Automate Mod Expression Examples
mod(8,3) => 2 mod(9,3) => 0 // float example mod(5.5,1.5) => 1 // with variable mod(variables(‘myNumber’), 3)
How To Use The Power Automate Mod Function
Follow the steps to use the Power Automate Mod function in a flow.
Create a new flow with trigger ‘Manually trigger a flow’
Add a new step by clicking on ‘+ New step’
Add a new step
Search for ‘initialize’ and click on ‘Initialize variable’
Add Initialize variable action
Setup Initialize variable: 1) Provide a name, 2) select type Integer, 3) Set value to ‘8’
Add a compose step by searching for ‘compose’ and clicking on ‘Compose’
Add Compose action
Setup compose action: 1) click into Inputs (popup appears), 2) click on ‘Expressions’, 3) set expression to ‘mod(variables(‘myNumber’), 3)’ 4) click on ‘OK’
Setup mod expression in Power Automate
Save and do a test run
Result test run – Power Automate Mod function example