Power Automate Mod Function Explained

Power Automate Mod Function

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

power automate mod expression
mod expression in Power Automate

To find the remainder when dividing two numbers, use the mod function. To obtain the integer quotient, use the div() function.

Syntax

mod(<dividend>, <divisor>)

Input parameters

  • 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.

Return value

  • 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.

  1. Create a new flow with trigger ‘Manually trigger a flow’

    power automate mod function new flow

    New flow

  2. Add a new step by clicking on ‘+ New step’

    power automate mod function new step

    Add a new step

  3. Search for ‘initialize’ and click on ‘Initialize variable’

    power automate mod function initialize variable

    Add Initialize variable action

  4. Setup Initialize variable: 1) Provide a name, 2) select type Integer, 3) Set value to ‘8’

    power automate mod function initialize variable setup

    Setup variable

  5. Add a compose step by searching for ‘compose’ and clicking on ‘Compose’

    power automate mod function add compose

    Add Compose action

  6. 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’

    power automate mod function compose setup

    Setup mod expression in Power Automate

  7. Save and do a test run

    power automate mod function test run result

    Result test run – Power Automate Mod function example

Leave a Comment

Your email address will not be published. Required fields are marked *