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

Selecting an object from an array variable without an apply to each loop?

(0) ShareShare
ReportReport
Posted on by 4
I'm somewhat of a beginner in Power Automate, but I haven't been able to find a solution for my specific use case. Any help would be greatly appreciated!
 
I have a Power Automate flow that queries our CRM's API to retrieve a list of companies using an HTTP GET request. I can only get 100 results per call, so I have to paginate it. I use an Apply to Each with an Append to array variable action to append the following information to my CompanyDetails variable from the Parse JSON that looks at that HTTP GET action:
 
 "Name": "@{items('Apply_to_each_-_Companies')?['entity']['name']}",
  "MainDomain": "@{items('Apply_to_each_-_Companies')?['entity']['domain']}",
  "Domains": "@{items('Apply_to_each_-_Companies')?['entity']['domains']}",
  "CompanyID": "@{items('Apply_to_each_-_Companies')?['id']}",
  "StageID": "@{items('Apply_to_each_-_Companies')?['entity']['fields'][0]['value']['data']['dropdownOptionId']}"
 
 
The purpose of this flow is to then conditionally save email attachments to SharePoint utilizing information from the above array variable. The problem I'm encountering is that later in the flow, I have quite a few conditions that it needs to check against; specifically, I need to check whether the SenderDomain (a string variable I set from an email with an attachment) exists within the Domains in the array variable, and then retrieve just the object where it matches. "Domains" is an array of strings that usually contains one string, but sometimes contains 2 or more strings.
 
In my working version of this flow, I achieved this with an apply to each that loops through the CompanyDetails array variable and a condition that checks whether the domain matches. However, since there's 3,000 companies (and growing) on the list, this tends to take a very long time and makes the flow run for hours.
 
Unfortunately, I can't just make an array variable of all domains in the list, as I will need to reference the StageID and MainDomain from the specific company object later in the flow for conditions. So for example, this would be an output for one object in the CompanyDetails array variable out of 3,000:
 
"Name": "Company",
"MainDomain": "company.com",
"Domains": "["company.com","company1.org"]",
"CompanyID": "123456789",
"StageID": "1111111"
 
Now imagine my SenderDomain variable was also "company1.org".
 
Is there a way to check the entire CompanyDetails array variable for the one that matches the SenderDomain variable and fetch the just that company entry without an apply to each loop that iterates over each company in the array variable?
 
 
I have the same question (0)
  • creativeopinion Profile Picture
    10,480 Super User 2025 Season 2 on at
    Selecting an object from an array variable without an apply to each loop?
    @MD-02121526-0 
    It's hard to offer any recommendations without seeing your full flow and the logic behind it. Toggle off the New Designer and click each action to expand it. Upload a screenshot of your flow in edit mode.
     
    From what I can tell, you probably don't need the append to array variable action. Instead, you should use a Select action to pull the values that you are interested in from your original array. 
     
    In the meantime, you might be interested in these YT Tutorials:


    Are you using the Microsoft Power Automate Filter Array Action wrong?
    In this video tutorial I’ll show you 3 practical ways to use the Filter Array action and how to use it properly.
     
    1️⃣ Cross-Referencing Data
    2️⃣ Filtering by Key
    3️⃣ Substring Matching 
     
    Did you know that the Condition action has a limit of 10 conditions? Although it might look like the Filter Array action can only accept one condition—this is not true. By using the advanced mode you can enter multiple conditions into a Filter Array action with an expression. 
     
    IN THIS VIDEO:
    ✔ 3 Ways to Use the Filter Array Action
    ✔ How to use the Scope Action to Group Actions
    ✔ How to Check the Number of Items Returned from a Filter Array Action
    ✔ How to Cross-Reference Data in Excel with a SharePoint List
    ✔ How the Filter Array Action Works
    ✔ How to Access the Dynamic Content from a Filter Array Action
    ✔ How to Filter Items by a Key
    ✔ How to Filter Items by Matching a Substring
    ✔ How to Use Multiple Conditions in a Filter Array Action
    ---
     
    Filter Array + Apply to Each: The Best Tip You Need to Know
    In this tutorial—I’m going to show you a quicker way to get the dynamic content from your Filter Array action—and it doesn’t require writing an expression.
     
    IN THIS VIDEO:
    ✔ How to Loop Through Filter Array Results in Power Automate
    ✔ Using Apply to Each with Filtered Arrays
    ✔ The Easiest Way to Access Dynamic Content from Filter Array
    ✔ Fixing Nested Apply to Each Actions
    ✔ When to Use Value vs. Body Dynamic Content
    ✔ Simplifying Power Automate Flows with Filter Array
    ✔ Troubleshooting Filter Array and Apply to Each Issues

    ---
    3 Mistakes YOU 🫵 are Making with the Apply to Each Action in your Microsoft Power Automate Flow
     
    In this video tutorial I’ll go over how to avoid these common mistakes when using the Apply to Each action in a Power Automate flow:
     
    1️⃣ Looping through a Single Item
    2️⃣ Creating Unnecessary Nested Loops
    3️⃣ Looping through an Unfiltered Array
     
    At the end of the video I share a few helpful insights when it comes to using the Apply to Each action in your flow.
     
    IN THIS VIDEO:
    ✔ How to Avoid the Apply to Each Action with a Single Item Array
    ✔ How to Use the item() Function to Access Dynamic Content in an Array
    ✔ How to Prevent Unnecessary Nested Apply to Each Action Loops
    ✔ How to Use the Select Action
    ✔ How to Convert an Array to a String with the Select Action
    ✔ How to Use the Filter Query Field
    ✔ How to Count the Number of Items in an Array
    ✔ How to Use a Condition Control
    ✔ How to Use the Concurrency Control
    ✔ How to Set a Top Count
    ✔ How to Use Compose Actions for Troubleshooting
     
     
     
    Hope this helps!
    Consider giving me a ❤️ if you liked my response!
    👉 Level up your Power Automate skills by checking out my tutorials on YouTube
    👉 Tips and Tricks on TikTok and Instagram
  • MD-02121526-0 Profile Picture
    4 on at
    Selecting an object from an array variable without an apply to each loop?
  • Suggested answer
    Fubar Profile Picture
    8,232 Super User 2025 Season 2 on at
    Selecting an object from an array variable without an apply to each loop?
    To find matches use an "Filter Array" action with a Contains condition to your array of values to match. (if a complex match can change it to the formula view and do more with the expression). 
     
    Often you find you can use a Filet Array instead of a loop if you are just looping to compare a value etc - there is a huge performance improvement using a Filter Array over an Apply to Each loop.
  • MD-02121526-0 Profile Picture
    4 on at
    Selecting an object from an array variable without an apply to each loop?
    Yes, I've tried the filter array action in a separate optimization attempt at this flow, but have not been able to get it to work. I think I will be able to remove the "Has Attachments" condition and instead include that as a filter within my Graph API HTTP GET call for the emails, however when I tried to implement the filter array action previously, I am unable to select the "Domains" within the array variable to assess it. I probably am just using it wrong, though, since I'm not familiar with the filter array action. I can't upload screenshots of that version of the flow since it's gone through many iterations since the test I'm referencing, but it's essentially the flow I posted screenshots of earlier, but using the Filter Array action after I set the SenderDomain variable. This is the error I would get:
     
    InvalidTemplate
    The execution of template action 'Filter_array_2' failed: The evaluation of 'query' action 'where' expression '@equals(item()['Domains'],variables('SenderDomain'))' failed: 'The template language expression 'equals(item()['Domains'],variables('SenderDomain'))' cannot be evaluated because property 'Domains' cannot be selected. Property selection is not supported on values of type 'String'. Please see https://aka.ms/logicexpressions for usage details.'.

    This is the code view for that filter array action:
    {
      "type": "Query",
      "inputs": {
        "from": "@variables('CompanyDetails')",
        "where": "@equals(item()['Domains'],variables('SenderDomain'))"
      },
      "runAfter": {
        "Set_variable_-_SenderDomain": [
          "Succeeded"
        ]
      }
    }
  • creativeopinion Profile Picture
    10,480 Super User 2025 Season 2 on at
    Selecting an object from an array variable without an apply to each loop?
    @MD-02121526-0 Can you show the input for the Filter Array action?

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 655 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 371 Moderator

#3
chiaraalina Profile Picture

chiaraalina 276

Last 30 days Overall leaderboard