Skip to main content

Notifications

Power Automate - General Discussion
Answered

Get a variable from filtered array

(0) ShareShare
ReportReport
Posted on by

I am trying to add version numbers into an SP list, but I can't figure out how to pull a variable from a filtered array.

  • I have an array that contains two items: Name and Version.
  • The number of items in the array is variable.
  • I use Filter Array in an Apply to Each to loop through a SharePoint list. For each item in the SharePoint list, my array is filtered down to a single item by comparing the item in the SP list to the items in my array.

Now this next part I am having trouble with. I need to get the "Version" out of that single item array. I am using compose (visible below) with variables('currentVersion')?[0]?['Version']. This works to get the item at index 0 of the unfiltered array, but I cannot figure out how to modify the expression to work on the Filter Array's Output. Changing 'currentVersion' to anything else gives me an error. I am sure I am missing something simple, but I am not sure what that is off-hand.

 

ABureaux_0-1636416575959.png

 

Categories:
  • ABureaux Profile Picture
    ABureaux on at
    Re: Get a variable from filtered array

    Derp. Silly me. I did previously try the expression you posted, but tried to nest it in the "Variable" expression (which obviously gave me an error).

     

    Everything is working beautifully now. Thank you!

  • Verified answer
    Gopala_Krishna Profile Picture
    Gopala_Krishna 1,457 on at
    Re: Get a variable from filtered array

    @ABureaux 

    to retrieve the action outputs of the "Filter Array" action you can use the expression body('Action Name'). Your Filter array action name is - "Filter array - Find the current version of survey" to complete the expression it would be

     

    body('Filter_array_-_Find_the_current_version_of_survey')

     

    To get select outputs you can add more elements to the formula such as body('Filter_array_-_Find_the_current_version_of_survey')[0]['Value'] to select the value property from the 1st element of array.

     

     

    If the information shared helps you please consider giving a thumbs up 👍 and mark solution as resolved ✔️

    Please follow my website PowerCards for more information related to Power Platform

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

Kickstarter Events…

Register for Microsoft Kickstarter Events…

Tuesday Tip #12 Start your Super User…

Welcome to a brand new series, Tuesday Tips…

Tuesday Tip #13 Writing Effective Answers…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,858

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,505

Leaderboard