web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Suggested answer

prevent "For each" block

(0) ShareShare
ReportReport
Posted on by 12
Hello,

For example, I read a item in a configuration list. The return value contains only one element with two or three columns.
If I now want to use a value from one of the columns in the return value, this is converted into a “For each” block. How can I prevent this? 
 
Thank you for your great support
 
Stefan
I have the same question (0)
  • Suggested answer
    Michael E. Gernaey Profile Picture
    48,732 Super User 2025 Season 2 on at
    prevent "For each" block
     
    Yes that is correct. Arrays themselves are accessible by the Ordinal position, properties are accessible by the name.
     
    PStork wrote out a specific example but that is for SharePoint, since I wasn't sure what you are using (originally it wasnt' stated), I was generalizing across any JSON structure.
     
    So exactly.
     
    Many times people do not want to add a Condition to check the length (I prefer to do it just for error handling), but even if you have a condition and check, most people will add an Apply to each to iterate through
    But if you know its just one record, then I just use the Ordinal as I save actions and time and money :-) against my quota
     
    I hope that answers you and good job honestly on understanding it right away
     
    Cheers

    If these suggestions help resolve your issue, Please consider Marking the answer as such and also maybe a like.

    Thank you!
    Sincerely, Michael Gernaey
  • Suggested answer
    Pstork1 Profile Picture
    67,916 Most Valuable Professional on at
    prevent "For each" block
    If you want any record other than the first one or the last one then the index will work.  If you are doing the equivalent of a Lookup where there is only one record then you can either use the Index or use First() or Last().  The index coding looks like this to get the first record.
     
    outputs('Get_items')?['body/value'][0]?['Title']
     
    The function coding looks like this
     
    first(outputs('Get_items')?['body/value'])?['Title']
     
    Either will work.  Both require typing the JSON directly in the Expression field in the dynamic content.

    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
     
     
  • SK-01091159-0 Profile Picture
    12 on at
    prevent "For each" block
    Thank you Paul and Michael for your great answer.
     
     
     
    This sounds very interesting. 
     
    For instance, when you get the body/value property from a List Rows present in a table, or Get Items, and if it returned back 10 rows, you could access a row by [0] through [9] and then access a column from that
     
    I have this small screenshot. 
     
     
    The action "Get items" returns only on item with columns (email, subject, ... ) . I have an object (email, subject, ... ). In the action "Variable" I want to write the return vaule from "Get items" into the object. 
  • Suggested answer
    Pstork1 Profile Picture
    67,916 Most Valuable Professional on at
    prevent "For each" block
    If you know the name of the column you want to access you just need to use the First() function to isolate the first record and then add ?['columnname'] to the end of the function.  You'll need to use the expressions tab in the dynamic content bar to enter the JSON, but it will keep the system from adding the For Each loop.
     

    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
     
  • Suggested answer
    Michael E. Gernaey Profile Picture
    48,732 Super User 2025 Season 2 on at
    prevent "For each" block
     
    Please share what it looks like. 
     
    The only reason an Apply to each runs (or For Each) is when there is an array
    Having 3 columns would not cause that, unless you are talking about an array of columns
    Having more than 1 row with 3 columns would.
     
    As an example, grabbing a row from Excel or SharePoint can have 10000 columns but it would not cause an Apply to each
     
    If you please share an example of the data (not just one line but the actual configuration of the data) then I can happily tell you.
     
    You would need either to know exactly which Row to grab the data from so you can use the Ordinal Position.
     
    For instance, when you get the body/value property from a List Rows present in a table, or Get Items, and if it returned back 10 rows, you could access a row by [0] through [9] and then access a column from that
     
    But if your columns are themselves an array in your data, then that changes it
     
    So once I see it and you give an example of what column can help you quickly.
     

    If these suggestions help resolve your issue, Please consider Marking the answer as such and also maybe a like.

    Thank you!
    Sincerely, Michael Gernaey

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

MS.Ragavendar – Community Spotlight

We are honored to recognize Ragavendar Swaminatha Subramanian as our September…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 760 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 429 Moderator

#3
Power Apps 1919 Profile Picture

Power Apps 1919 327

Last 30 days Overall leaderboard