web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Help Selecting a rando...
Power Automate
Answered

Help Selecting a random element from array

(0) ShareShare
ReportReport
Posted on by 2

Hello, hoping for a little assistance,

I am creating a birthday announcement automation for my organization. I'm using a dataverse connector to get contact info from D365, OneDrive to write to an Excel file for testing, and email, to test sending the message. I am trying to store a list of birthday quotes in an array, and then pick a random item from that list later in a for each loop and use it in a email/excel.  The trouble that I am having is that when I attempt to select a random item and store it in a variable, it appears that the variable is blank.  

Here's what I have:

I declare the array variable and set the value.

I declare the variable to hold the selection being picked from the array, (leaving it blank so I can set its value next).  (ignore the comment, that was from a previous try)

Within my for each loop, I attempt to set the variable with this expression

body('varBdayQuotes')?['value'][rand(0,length(body('varBdayQuotes')?['value']))]

When I test the flow, the variable varCurrentQuote appears to be empty.

AllCaptures1.png

 

 

Any help would be appreciated, thanks!

 

-ER

Categories:
I have the same question (0)
  • Verified answer
    Rahber Profile Picture
    1,935 on at

    I think you mixed the tutorial you were following. The body and how that was for a SharePoint action of Get Item. 

     

    Since because you are using an array variable to store your birthday quotes try using this expression

     

    variables('varBdayQuotes')[rand(0,length(variables('varBdayQuotes')))]

     

    Please click Accept as Solution if it resolved your problem or give it a Thumbs Up if it helped you in anyway this will allow other people to search correct solutions effectively.

    Thanks,
    Rahber

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 250 Super User 2026 Season 1

#2
Expiscornovus Profile Picture

Expiscornovus 222 Most Valuable Professional

#3
Haque Profile Picture

Haque 174

Last 30 days Overall leaderboard