
I thought yesterday of creating a PowerApp to enjoy playing some games between colleagues at work! I will be posting soon both the application and the game idea.
In order to reach my target, I wanted to generate a random number between 1 and 4 that could define the player who must start the game.
After doing some maths, I was able to conclude the general formula to be used in order to generate any random number using PowerApps. Here are the parameters:
In order to generate a random integer number between A and B use the Following formula:
Set( FinalResult , Round( Rand() * (B-A) + A , 0) )
A being the smallest possible number
B being the highest possible number
So in my game, this is what the formula looks like:
Set(playerRole, Round( Rand() * (4-1) + 1, 0))
Stay safe everyone! Stay at home :)