In Power Automate, in few of the scenarios we need to generate random number example to prepare a unique name with text and combination of Unique number so as to provide a quick test data then rand function is used.
Login to the required Power Apps environment using URL make.powerapps.com by providing user name and password and click on Flows on the left hand side as shown in the below figure.
After Step 1, Click on New Flow and select instant cloud flow and provide the trigger as Manually trigger a flow and click on Create as shown in the below figure.
After Step 2, click on + New Step and under Choose an operation and in text box type compose and select Compose Data Operation as shown in the below figure.
After Step 3, rename compose title with rand Function and click on Inputs and select 2nd tab Expression and type rand and observe it expect 2 parameters first 1 minValue with integer type , 2nd is maxValue of integer type we can pass as shown in the below figure.
After Step 4, rand have the following syntax
rand(minValue: integer,maxValue : integer)
so provide the value as example
and click on OK shown in the below figure.
After Step 5, Save and Test flow after clicking on Run Flow and Done and click on OK shown in the below figure.
- Make sure to save and run the flow whenever you try expressions.
- MS documentation is found at https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#rand
- As an example, maxValue 9999 as in Step 5, you can provide any other value of your choice.
Conclusion: In this way one can easily generate a random number in few minutes and use it for required scenario.