cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Get Last Item in Array

I can succesfully retrieve a value from the first item in an array using this: 

body('TrackCont')?['Containers'][0]['eta_final_delivery']

Can someone tell me how to pull the same from the last item in the array? Array is of indeterminate length?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Try the below in a compose

 

last(body('TrackCont')?['Containers']))

 

See the runtime history and see what it outputs

 

 

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

Power Automate Video Tutorials

View solution in original post

7 REPLIES 7
Highlighted
Super User III
Super User III

Hi @Chauc3r 

 

You can use the last() expression to get the last value from the index of the array.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

Power Automate Video Tutorials
Highlighted
Frequent Visitor

Hi @abm,

Apologies, I'm rather out of my depth here.

I tried rewriting that as 

last('TrackCont')?['Containers']['eta_final_delivery']

but it didn't like it!

 

Also if you were able to point me at an idiot guide to flow syntax that be amazing!

Looks like you need a closing )  

last('TrackCont')?['Containers']['eta_final_delivery'])

Highlighted

Hey @haroldbk_msft ,

I tried multiple versions of that guy with no luck.....

 

Computersaysno.png

 

100% confident I'm doing something idiotic!

Highlighted
Super User III
Super User III

Try the below in a compose

 

last(body('TrackCont')?['Containers']))

 

See the runtime history and see what it outputs

 

 

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

Power Automate Video Tutorials

View solution in original post

Highlighted
Super User III
Super User III

Also see what this returns

 

body('TrackCont')?last(['Containers'])

 

Let me know how it goes. Once either of these expression works then its easy to extract the properties.



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

Power Automate Video Tutorials
Highlighted
Frequent Visitor

Sticking things into a compose and playing with them is probably the most useful tip I've ever had with Flow! Just makes things so much more visible!
Thanks!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (16,082)