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 / Get Random Item Value ...
Power Automate
Answered

Get Random Item Value from Excel / Array

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I am new to power automate and i didnt found a soultion, on how i can get a random item value out of an array. If tried https://www.flyingpolymath.com/post/expression-interlude-random-item-from-array-in-power-automate ; https://powerusers.microsoft.com/t5/Building-Flows/Help-Selecting-a-random-element-from-array/m-p/956570#M134082 and several other things, but somehow i dont get it done. 

 

Idea: The goal would be to select from an excel list, all rows which have an empty value in a specific column. Then select from this subset/array an random item and get the value"Number"/"Nummer" from this item. (Later this item would be changed in the excel list and filled out with some MS-Forms data). 

 

Flow: So i get the excel list from my onedrive folder (works sucessful), then get the subset out of the excel list with an array filter (works sucessful) and then try with the action "compose" to get an random item out of the array (doenst work).

I have entered the expression in the compose action to get an random item by myself.

 

Problem

I tried the following expression: 

 

 

body('Freie_Nummern')?['body'][rand(0, length(body('Freie_Nummern')?['body']))]?['Nummer']

 

 

 

Since it didnt worked, i tried to simplify it and only get an whole array-item, with the following code: 

 

 

body('Freie_Nummern')?['body'][0]
body('Freie_Nummern')?['value'][0]

 

 

 

But also with this "easy" expression, the error-report always says, that i have to select an array element with an integer expressions. So i think, that somehow i am not using the correct attribute with "body" or "value".  Could somebody point my to the correct syntax i would need to use? Thanks and sorry for the long text: )

 

timosqs_0-1650979297318.png

Flow:

timosqs_2-1650979949193.png

 

 

 

Error Message: 

German: Vorlagensprachausdrücke in den Eingaben der Aktion "Verfassen" in Zeile "0" und Spalte "0" können nicht verarbeitet werden: Der Vorlagensprachausdruck "body('Freie_Nummern')?['body'][0]" kann nicht ausgewertet werden, weil die Eigenschaft "body" nicht ausgewählt werden kann. Arrayelemente können nur mit einem Ganzzahlindex ausgewählt werden. Weitere Informationen zur Verwendung finden Sie unter https://aka.ms/logicexpressions..

 

English: Template language expressions in the inputs of the "Compose" action in row "0" and column "0" cannot be processed: The template language expression "body('Free_Numbers')?['body'][0]" cannot be evaluated because the "body" property cannot be selected. Array elements can only be selected with an integer index. For more information on usage, see https://aka.ms/logicexpressions..

Categories:
I have the same question (0)
  • Verified answer
    VictorIvanidze Profile Picture
    13,079 on at

    Hi @Anonymous,

    use this syntax:

    body('Freie_Nummern')[0]?['Nummer']

     

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 86 Super User 2026 Season 1

#2
Haque Profile Picture

Haque 55

#3
Ellis Karim Profile Picture

Ellis Karim 53 Super User 2026 Season 1

Last 30 days Overall leaderboard