Skip to main content
Community site session details
Power Apps - Building Power Apps
Answered

Find Element in Array and get Position ID

Like (0) ShareShare
ReportReport
Posted on 8 Mar 2022 12:53:09 by 63

Hello, community,

 

in Power Automate, I'm looking for a simple way to find a word (or element in general) in my array and get its position ID. 

 

So let's say, I have this array:

 

[

  "A",

  "B",

  "C",

  "D",

  "E"

]

 

I want to search for "C" and get its position ID, so "2". Is there a simple way to achieve that?

 

 

Best regards,

Dog

  • Verified answer
    DamoBird365 Profile Picture
    8,942 Microsoft Employee on 20 Jul 2022 at 19:58:43
    Re: Find Element in Array and get Position ID

    Hi all,

     

    I saw this problem being referenced on Reddit and thought I could provide you with a solution.  I've started with the array, followed by a select that uses range starting at 0, using length of the array for the number of values, 0,1,2,3,4.  Note that the index for an array starts at 0.  I create a string key based on the position from range outputs('compose')?[item()] and position based on the range item(). 

     

    DamoBird365_0-1658343101981.png

    This is what the flow run for select creates:

    DamoBird365_3-1658343733853.png

     

    Using filter array, I can search for the string value "Pie" based on equalling item()['String'] i.e. the key created in the select. This will return one object in the array and by using first, we can return the position first(body('Filter_array'))?['Position']

     

    DamoBird365_1-1658343317028.png

    The result is position 4 (as indexes run 0,1,2,3,4).  

    DamoBird365_2-1658343460590.png


    Cheers
    Damien

    Please take a look and subscribe to my YouTube Channel for more Power Platform ideas and concepts. Thanks

     

     

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Loading complete