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
Power Automate Rand Function
Generate a random number within a given range, where the lower bound is included but the upper bound is excluded.
Syntax
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.
rand(1,11)
// 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.
-
Create a new flow with trigger ‘Manually trigger a flow’
New 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) click on in value text field (popup appears),  4) click on ‘Expressions’, 5) set expression to ‘rand(1,11) click on ‘OK’
Setup rand expression in Power Automate
-
Save and do a test run
Result test run – Power Automate Rand function example