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

Notifications

Announcements

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

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,073 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard