Showing results for 
Search instead for 
Did you mean: 

Bypass Apply to each loop on single record

The Problem:

Power Automate creates a 'Apply to each' loop when selecting dynamic content from a action that Lists items, folder, or anything.

In most cases this is awesome and creates a nice smooth workflow.


However, what about when you know exactly what you want to look for and you know its only going to be 1 record, item, whatever is going to be returned. Power Automate will still make you use the 'Apply to each' loop.


This may not be a such a terrible thing, but if you need to do multiple things underneath that action, you will have to put them in the loop as well (if you need any data or reference to that action)


Why not use a get record instead:

In some cases, yes a 'Get' action will be perfect, but this is only if you know the "Key".

In my example I only know the users 'Full Name', so I cannot use the CDS 'Get record' action.



Regardless of what connector or actions you use, this method will allow you to bypass the loop.



Okay now on to the magic..


In my example Flow:

  • I am using a 'Compose' action to have my Full Name stored.
  • I am using the 'List records' CDS action to list records from the default Users table entity.
  • I am using a ODATA filter on the 'List records' which I am using to filter fullname
  • Under the 'List records' I use a 'Compose' action to store the users ID(Primary Key from CDS) and the users Email Address

pic1.pngMy List Records with my Odata filter


pic2.pngAdd a Compose action below the List action. And select Expression


pic3.pngType anything, this is to keep us in Expression mode when we switch back to Dynamic Content tab


pic4.pngIf you see the fx Logo in the Dynamic Content Tab, you have done this correctly


pic5.pngRemove what you had, and Click the Value of the action you want to bypass the loop with


pic5-5.pngRemove the ? and add [0] This is saying we want the first record only. Since this returns an array we say 0 as this is the first record in an array


pic6.pngafter the [0] we type what the field name is, in this format: ['feildname']


pic7.pngClick OK.. I usually like to put the Expression in a Comment



pic8.pngHere is another example. Getting the email address from the List records

The expression is:
















The only thing you have to watch out for is when there is a empty record. This will cause an error if the record is empty.

This can easily be fixed using a Condition If block before the Compose to check if value is empty using the empty() expression.



I hope anyone finds this useful. This boosts performance greatly when you only need one record.


If you like my post please hit the "Thumbs Up"


Hi Josh,


Great post.


Have you considered using the first() function instead of the [0].


The [0] would potentially return an error when the array is empty where first would return null.

Very thoroughly documented steps and timely. Thanks Josh for a great post!

Thank you all.


@PieterVeenstra  Awesome idea. However I like to throw the error if its blank, if i am using this method I am usually expecting at least one record. Which will be easy to configure a run after if needed.

Meet Our Blog Authors
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Cambridge UK Power Platform User Group Leader, Technical evangelist and speaker. Always says yes to coffee! #LetsGetCoffee
  • Passionate #Programmer #SharePoint #SPFx #Office365 #MSFlow | C-sharpCorner MVP | SharePoint StackOverflow, Github, PnP contributor
  • I am building business processes and applications that are easy for users' to stick to, so they can follow and understand them. In overall I transform processes to be more reliable and effortless. I am a proud co-organizer of SharePoint Saturday Warsaw and active community member, blogger and international speaker.