πŸš€ Power Automate Tip: Accessing Specific Items in JSON Without “Apply to Each

 


One of the most common frustrations in Power Automate is dealing with the “Apply to each” loop when you only want a single item from an array (for example, the 4th item).

Loops add unnecessary complexity, slow down your flow, and make debugging harder. Luckily, you can avoid them with simple array indexing expressions.


✅ The Scenario

Let’s say you’re using the SharePoint “Get items” action to pull Paid Time Off (PTO) requests.
The output looks like this:

json

[ {"Title": "Vacation"}, {"Title": "Sick Leave"}, {"Title": "Work from Home"}, {"Title": "Maternity Leave"} ]

You only need the 4th item (Maternity Leave) — but without looping through everything.


πŸ” Two Easy Solutions

1️⃣ Direct Index Reference

Power Automate arrays are zero-based, so the 4th item is at index [3].

Expression:

powerfx

body('Get_items')?['value'][3]?['Title']

πŸ‘‰ Output: Maternity Leave


2️⃣ Using skip() Function

Another neat trick is using skip() to drop the first N items and grab the next one.

Expression:

powerfx

first(skip(body('Get_items')?['value'], 3))?['Title']

πŸ‘‰ This skips the first three items and returns the 4th.


⚠️ Best Practice: Handle Missing Data

What if the list doesn’t have four items? To avoid errors, wrap your expression with a condition:

powerfx

if( greater(length(body('Get_items')?['value']), 3), body('Get_items')?['value'][3]?['Title'], 'Not Found' )

πŸ‘‰ If there are fewer than 4 items, the flow safely returns “Not Found” instead of failing.


🎯 Bonus: Get the Last Item

Want the last record, regardless of length? Use:

powerfx

last(body('Get_items')?['value'])?['Title']

Perfect for “latest record” scenarios!


✨ Final Thoughts

By using array indexing and functions like skip() and last(), you can eliminate unnecessary Apply to each loops in Power Automate.

This makes your flows:

  • 🏎 Faster

  • 🧹 Cleaner

  • πŸ” Easier to maintain

Next time you need a single item from a JSON array, skip the loop and go direct. πŸš€

Comments

Popular posts from this blog

πŸ€– Copilot vs Microsoft Copilot vs Copilot Studio: What’s the Difference?

Automating Unique Number Generation in Dynamics 365 Using Plugins

In-Process vs Isolated Process Azure Functions: What’s the Difference?