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
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().
This is what the flow run for select creates:
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']
The result is position 4 (as indexes run 0,1,2,3,4).
Cheers
Damien
Please take a look and subscribe to my YouTube Channel for more Power Platform ideas and concepts. Thanks