Flow Friday: Getting random row from Excel

Finally back for Flow Friday after some much needed rest over the holidays. This week is sort of a proof of concept. There are times when you need to just get a random value. This could be for a lottery or get a random name for the person that should take out the trash this week.

  1. Create an Excel Sheet in OneDrive with a table containing all of the names you need to randomize
  1. Go to Microsoft Power Automate and create a new flow
  2. Since I want it to run automatically I set it on a schedule
  1. Next we read the Excel file and figure out the number of rows
  1. We then create a variable that is a random number between 0 and [number of rows in the table]
Formula: rand(0,int(length(body(‘ListRows’)?[‘value’])))
  1. Then we get the name column form the row with the random number
Formula: body(‘ListRows’)?[‘value’]?[variables(‘RandomRow’)]
  1. Finally I sent the name in a notification

That is all… I will now get a notification with the name of the person that will take out the trash 🙂

Leave a Reply