Power Automate Rand Function Explained

Power Automate Rand Function

The Power Automate Rand function generates a random integer number for a given number range.

In this article, I’ll introduce you to the rand function and will provide a step-by-step guide on how to use the function in a Microsoft flow.

Power Automate Rand Function

Generate a random number within a given range, where the lower bound is included but the upper bound is excluded.


rand(<minValue>, <maxValue>)

Input parameters

  • minValue (mandatory): The integer with the lowest value in the range.
  • maxValue (mandatory): The integer immediately succeeding the one with the highest value within the range that the function can produce.

Return value

  • Returns a random integer generated from the given range.

Power Automate Rand Expression Example

How do you generate a random number in power automate? Here is an example how to generate a random number between 1 and 10.

// can be any number from 1 to 10 => 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9 or 10

How To Use The Power Automate Rand Function

Follow the steps to use the Power Automate Rand function in a flow.

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

    power automate rand function new flow

    New flow

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

    power automate rand function new step

    Add a new step

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

    power automate rand function new step init var

    Add Initialize variable action

  4. Setup Initialize variable: 1) Provide a name, 2) select type Integer, 3) click on in value text field (popup appears),  4) click on ‘Expressions’, 5) set expression to ‘rand(1,11) click on ‘OK’

    power automate rand function config init var

    Setup rand expression in Power Automate

  5. Save and do a test run

    power automate rand function test run result

    Result test run – Power Automate Rand function example

Leave a Comment

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