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
Answered

Apply to each loop

(0) ShareShare
ReportReport
Posted on by 41

So, I have this CSV that has been properly parsed into JSON format. I have the right conditions under an apply to each to recognize if the first character is a number, if the whole thing is 3 characters and has the last condition that it starts with 1,2,3,4,7,9 and then counts the specific department numbers. The issue is, the apply to each is taking ages. Is there a way to circumvent apply to each or speed it up? the degree of parallelism is up to 35 atm also

I have the same question (0)
  • Unknown geen idee Profile Picture
    1,757 on at
    Re: Apply to each loop

    Dear M,

    From what you share ... some checking with numbers/characters ... there is no way that the Apply to each loop will take this long. Something else is going on ..., maybe nested/nested loops or a stalled file action, ... but without a view on the actual actions you have inside your Apply to each loop, this is becomes a very wide guessing game.

    Suggest you share the actions/screenshot of your flow (without sensitive details).

     

    Happy flowing,

    Koen

     

  • VictorIvanidze Profile Picture
    12,839 on at
    Re: Apply to each loop

    If you are talking about JSON array, try to use "Filter array" action.

  • Matthy79 Profile Picture
    4,178 Super User 2024 Season 1 on at
    Re: Apply to each loop

    As @VictorIvanidze  mentioned “Filter array” will do the work. After that you only apply to each filtered item and won’t need any other check inside the apply to each.

  • MooseGooseLoose Profile Picture
    41 on at
    Re: Apply to each loop

    Screenshot 2023-06-30 114727.pngScreenshot 2023-06-30 114753.pngI'm pretty sure I'm messing this up because it's not working fully and properly

  • MooseGooseLoose Profile Picture
    41 on at
    Re: Apply to each loop

    Actual better response. I'm not sure how to amend these and make it actually work?Screenshot 2023-06-30 131915.pngScreenshot 2023-06-30 132334.png

  • Matthy79 Profile Picture
    4,178 Super User 2024 Season 1 on at
    Re: Apply to each loop

    First of all.

     

    If you have the filter array correct, you won’t need any other condition (switch in your case) inside of “apply to each”.

     

    What is your Schema for parse json? (Please post it here)

    And what property do you want to filter?

  • MooseGooseLoose Profile Picture
    41 on at
    Re: Apply to each loop

    I thought my message already came through which is why I was a little confused.

    My column I'm trying to filter is the Employee Department Number and then filter out the 20 numbers I need, count each one and then spit out the total for each of the 20 in a tabular format

    My JSON schema is:

    {
        "type""array",
        "properties": {
            "content": {
                "type""array",
                "items": {
                    "type""object",
                    "properties": {
                        "EmployeeNumber": {
                            "type""string"
                        },
                        "LastName": {
                            "type""string"
                        },
                        "FirstName": {
                            "type""string"
                        },
                        "PositionTitle": {
                            "type""string"
                        },
                        "IsSupervisor": {
                            "type""string"
                        },
                        "SupervisorNumber": {
                            "type""string"
                        },
                        "Email": {
                            "type""string"
                        },
                        "HomeLocationCode": {
                            "type""string"
                        },
                        "LoginLocationCode": {
                            "type""string"
                        },
                        "UserID": {
                            "type""string"
                        },
                        "Password": {
                            "type""string"
                        },
                        "SecurityGroupName": {
                            "type""string"
                        },
                        "Employee Department Number": {
                            "type""string"
                        },
                        "Flag": {
                            "type""string"
                        },
                        "Company": {
                            "type""string"
                        },
                        "DateOfHire": {
                            "type""string"
                        },
                        "DateOfBirth": {
                            "type""string"
                        },
                        "StreetAddress": {
                            "type""string"
                        },
                        "City": {
                            "type""string"
                        },
                        "State": {
                            "type""string"
                        },
                        "ZipCode": {
                            "type""string"
                        },
                        "PhoneNumber": {
                            "type""string"
                        },
                        "HourlyWage": {
                            "type""string"
                        },
                        "SSN": {
                            "type""string"
                        },
                        "WorkStatus": {
                            "type""string"
                        },
                        "EmergencyContact": {
                            "type""string"
                        },
                        "EmergencyPhone": {
                            "type""string"
                        },
                        "Gender": {
                            "type""string"
                        },
                        "Contractor": {
                            "type""string"
                        },
                        "ContractorName": {
                            "type""string"
                        },
                        "ContractExpiry": {
                            "type""string"
                        },
                        "Termination Date": {
                            "type""string"
                        },
                        "ContractorNotes": {
                            "type""string"
                        },
                        "MiddleName": {
                            "type""string"
                        },
                        "LicenseType": {
                            "type""string"
                        },
                        "CultureName": {
                            "type""string"
                        },
                        "ToolbarName": {
                            "type""string"
                        },
                        "ShortDate": {
                            "type""string"
                        },
                        "ShortTime": {
                            "type""string"
                        },
                        "LongDate": {
                            "type""string"
                        },
                        "LongTime": {
                            "type""string"
                        },
                        "Pay Group": {
                            "type""string"
                        },
                        "Suffix": {
                            "type""string"
                        },
                        "Shift": {
                            "type""string"
                        },
                        "Groups": {
                            "type""string"
                        },
                        "EmployeeType": {
                            "type""string"
                        },
                        "PasswordUpdate": {
                            "type""string"
                        },
                        "ForcePasswordChange": {
                            "type""string"
                        },
                        "DisplayName": {
                            "type""string"
                        },
                        "SecondaryPassword": {
                            "type""string"
                        },
                        "SecondaryPasswordUpdate": {
                            "type""string"
                        },
                        "TimeZone": {
                            "type""string"
                        },
                        "OverrideTimeZone": {
                            "type""string"
                        },
                        "Location": {
                            "type""string"
                        }
                    },
                    "required": [
                        "EmployeeNumber",
                        "LastName",
                        "FirstName",
                        "PositionTitle",
                        "IsSupervisor",
                        "SupervisorNumber",
                        "Email",
                        "HomeLocationCode",
                        "LoginLocationCode",
                        "UserID",
                        "Password",
                        "SecurityGroupName",
                        "Employee Department Number",
                        "Flag",
                        "Company",
                        "DateOfHire",
                        "DateOfBirth",
                        "StreetAddress",
                        "City",
                        "State",
                        "ZipCode",
                        "PhoneNumber",
                        "HourlyWage",
                        "SSN",
                        "WorkStatus",
                        "EmergencyContact",
                        "EmergencyPhone",
                        "Gender",
                        "Contractor",
                        "ContractorName",
                        "ContractExpiry",
                        "Termination Date",
                        "ContractorNotes",
                        "MiddleName",
                        "LicenseType",
                        "CultureName",
                        "ToolbarName",
                        "ShortDate",
                        "ShortTime",
                        "LongDate",
                        "LongTime",
                        "Pay Group",
                        "Suffix",
                        "Shift",
                        "Groups",
                        "EmployeeType",
                        "PasswordUpdate",
                        "ForcePasswordChange",
                        "DisplayName",
                        "SecondaryPassword",
                        "SecondaryPasswordUpdate",
                        "TimeZone",
                        "OverrideTimeZone",
                        "Location"
                    ]
                }
            },
            "schema": {
                "type""object",
                "properties": {
                    "type": {
                        "type""string"
                    },
                    "items": {
                        "type""object",
                        "properties": {
                            "type": {
                                "type""string"
                            },
                            "properties": {
                                "type""object",
                                "properties": {
                                    "EmployeeNumber": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "LastName": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "FirstName": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "PositionTitle": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "IsSupervisor": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "SupervisorNumber": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "Email": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "HomeLocationCode": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "Password": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "Employee Department Number": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "Flag": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "DateOfHire": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "DateOfBirth": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "StreetAddress": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "City": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "State": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "ZipCode": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "PhoneNumber": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "EmergencyContact": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "Gender": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "Termination Date": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "MiddleName": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "Shift": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "EmployeeType": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "ForcePasswordChange": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "DisplayName": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "TimeZone": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "Location": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "HourlyWage": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "Pay Group": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "EmergencyPhone": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "LoginLocationCode": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "UserID": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "SecurityGroupName": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "LicenseType": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "Groups": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    }
                                }
                            },
                            "required": {
                                "type""array",
                                "items": {
                                    "type""string"
                                }
                            }
                        }
                    }
                }
            }
        }
    }
  • Matthy79 Profile Picture
    4,178 Super User 2024 Season 1 on at
    Re: Apply to each loop

    Employee Department Number is of type string. You compare it to a number. You will have to convert it to a number OR convert 661 to a string.

  • MooseGooseLoose Profile Picture
    41 on at
    Re: Apply to each loop

    I must be dumb as heck because I've not gotten a count yet

     

    Should this stay as integer or changed to string? (This a step before the parsing into JSON)

    Screenshot 2023-07-10 093959.png

     

    I still feel like I'm doing this part wrong

     

    Screenshot 2023-07-10 094109.png

     

    or is it this one?

     

    Screenshot 2023-07-10 094157.png 

  • Verified answer
    Matthy79 Profile Picture
    4,178 Super User 2024 Season 1 on at
    Re: Apply to each loop

    This will both not work.

     

    You won’t need a variable. If you use filter array you normally compare something from each item in an array with an expression or a value. As far as I understood you want to filter all elements where “Employee Department Number” is 661. What is “From” in your “Filter array” action? Why don’t you use the dynamic content from Parse JSON inside the condition?

     

    Maybe it would be easier you provide sample data and desired output and so I can build a flow that will do everything.

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…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 722 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 461 Moderator

#3
developerAJ Profile Picture

developerAJ 283

Last 30 days Overall leaderboard