cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Chauc3r
Helper I
Helper I

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
abm
Super User
Super User

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
abm
Super User
Super User

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

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'])

Hey @haroldbk_msft ,

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

 

Computersaysno.png

 

100% confident I'm doing something idiotic!

abm
Super User
Super User

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
abm
Super User
Super User

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

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
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (3,581)