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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Get column value from ...
Power Automate
Unanswered

Get column value from List 1, search it in List 2, if a match is found, compare two different columns

(0) ShareShare
ReportReport
Posted on by 23

Hello All,

I have two list: one with Users, and one with Departments.

The first one has the following columns: User / Email / Department / Group
The second one has the following columns: Department / BU

In the first list, sometimes there is a discrepancy between the Department and the Group and I want to fix this, like so:

Go through each of the items in the USERS_LIST, get the Department value, search for it in the DEPARTMENTS_LIST (it contains only unique values), if a match is found, compare the DEPARTMENTS_LIST.BU.value with USERS_LIST.GROUP.value ... if those are not equal, return the DEPARTMENTS_LIST.BU.value

I've tried: Get Items for USERS_LIST > Apply to each of these items > Get Items from DEPARTMENTS_LIST using filter Department eq 'USER_LIST.Group.value' > Condition: USERS_LIST.Group.Value is equal to DEPARTMENTS_LIST.BU.value > send email with the value

But it doesn't work...

Any idea on how do achieve this?

Thanks!

Categories:
I have the same question (0)
  • AlexandruChiser Profile Picture
    23 on at

    I've done this so far, but it takes 30+ minutes to run for 2000 entries...

    AlexandruChiser_2-1703168255663.png

     

    AlexandruChiser_1-1703168232058.png

     

    At then I just send an email with the string variable... 

  • Matthy79 Profile Picture
    4,180 Super User 2024 Season 1 on at

    If you provide sample data (JSON and not Screenshots) and a desired output, I will create a solution.

  • creativeopinion Profile Picture
    10,502 Super User 2025 Season 2 on at

    @AlexandruChiser 

    The logic of your flow needs to be adjusted. Using and Apply to Each and condition action to run a check for each item (especially if you have a large list is very inefficient). Also, best practice is to run a Get Items action outside of an Apply to Each action and use a Filter Array action instead. You should only run a Get Items action once for each list/library in your flow—rather than running it multiple times.  

    To learn more about how to use the Filter Array action, please refer to this recent YT Tutorial I uploaded.

     

    To further improve the efficiency of your flow—you'll want to try to avoid setting variables unless you absolutely need them. In your case—you don't need them. The concurrency control in the Apply to Each action can be toggled on when you aren't setting any variables inside the action. If you are, you would have to leave this off.

     

    You can turn on the concurrency control for any of your Apply to Each actions in your flow—as long as you aren't setting a variable (otherwise this can cause unexpected results). The concurrency control will run the Apply to Each action concurrently (same time—up to 50 instances at once). 

    creativeopinion_12-1703366775315.png

    creativeopinion_11-1703366736171.png

    A couple of things for you to consider:

    • How often do you plan on running this automation? Do you want it to run on a schedule?
    • After the automation has run—what are the chances the information in the Users list would change again? Would someone manually go in and edit it after you've run the automation?
    • Can you mark items that have been checked and edited so that you don't need to run the automation on those items again? This would reduce the amount of time it takes your flow to run as you can specify items that have not been edited via the automation so that you can leave those items (already changed) out the next time you run the automation again.

    Tip: Rename your action to keep things organized. Use Scope actions to group actions together so you can quickly collapse multiple actions with a single click. Run tests at each stage of your flow to confirm the outputs. 

    Flow Logic

    Since you want to look up the Department List and run a cross-check against the Users list you'll want to do the following:

    • Get Users List – Ideally you'd be filtering out this list as mentioned above
    • Get Dept List – Not necessary to filter unless there are inactive departments (in which case you should filter those out.
    • Loop through each department
      • Filter out users by current dept being looped through and cross-checking the BU value (in my demo case below it'll be the Dept Role) with a Filter Array action. Rather than checking each user individually.
      • If there isn't a match — update the item.
        With this flow logic you are streamlining your flow by looping through the depts and running a cross-check on multiple items at once with the Filter Array action. Only if there isn't a match, would you run an update on an item.

     

    You'll need to use the Classic editor to follow along.

    creativeopinion_1-1703389657294.png

    Get Users List

    Add a Get Items action to return the list of users. Tip: Depending on how large your list is, I'd recommend limiting the number of items returned to a small number while you are building and testing your flow. This will help to speed up your flow run. 

    How to Look Up SharePoint List and Match in Power Automate - Step 1.png

    Get Dept List

    Add a Get Items action to return the list of departments.

    How to Look Up SharePoint List and Match in Power Automate - Step 2.png

     

    Select User Fields

    Add a Select action to your flow. The Select action allows you to choose specific fields from the data retrieved—in this case from the Get Items (User List) action.

    creativeopinion_0-1703371519740.png

    Important: Since you have TWO Get Items actions in your flow you'll need to ensure you are selecting the dynamic content from the right action. This is why it's important to name your actions.

     

    In this case, you only need to return the following fields:

    • ID
    • Dept
    • BU (Department Role in my Case)
    • Title (this is only necessary if your title field is a required field in your list—if not you can omit this)

     

    In the from field, insert the value dynamic content from the Get Items action (which returns items from the User list).

     

    How to Look Up SharePoint List and Match in Power Automate - Step 3.png

    Enter a key in the left column and insert the dynamic content from the Get Items action in the right column. Repeat this for each dynamic content you'd like to return from the User list.

    How to Look Up SharePoint List and Match in Power Automate - Step 4.png

    If you are returning values from a choice column you'll need to ensure you are selecting the value dynamic content for the choice column.

    How to Look Up SharePoint List and Match in Power Automate - Step 5.png

    Run a test. Verify the outputs from the Select action.

    How to Look Up SharePoint List and Match in Power Automate - Step 5a.jpg

     

    Loop through Each Department

    Add an Apply to Each action. Insert the value dynamic content from the Get Items action that is returning the list of Departments. Don't forget to turn on the concurrency control!

    How to Look Up SharePoint List and Match in Power Automate - Step 13.png

    Add a Compose action to confirm the current dept being looped through. This step is optional however I find that it can be helpful especially with complex flows—it'll help you better understand what's going on as well as identify any issues with your flow early on.

    How to Look Up SharePoint List and Match in Power Automate - Step 14.png

     

    Filter User Items

    Add a Filter Array action to your flow—ensure you've nested this inside the Apply to Each action. You'll use this action to filter the items returned from your User list by the current department being looped through.

    How to Look Up SharePoint List and Match in Power Automate - Step 21.png

    In the From field, insert the Output from the Select action.

    How to Look Up SharePoint List and Match in Power Automate - Step 22.png

    In the first value field, you'll need to insert an expression to access the dynamic content of the department from within the Select action. You'll need to use the following expression:

    item()?['']

    In between the single quotes you'll need to insert the dynamic content key. Remember, you set this key in the Select action—it's Dept in my case (it might be different in your case depending on the key you entered).

    How to Look Up SharePoint List and Match in Power Automate - Step 23.png

    Enter the key between the single quotes.

     

    Keep the operator as is equal to. In the second value field, insert the output from the Compose action above (which contains the current dept being looped through.

    creativeopinion_0-1703393022844.png

     

    Whenever I use a Filter Array action, I always like to return the count of items returned in a Compose action. This is helpful when building a flow and can also be used to troubleshoot your flow.

     

    Insert a Compose action. Add an Expression. Use the length() function.

    SharePoint List Match Step 25.png

    Select the Dynamic content tab and insert the body dynamic content from the Filter Array action into the length() function.

    SharePoint List Match Step 26.png

    Run a test. Review the output of the Compose action. The number displayed should reflect the number of Users assigned to the current dept.

    creativeopinion_0-1703379200191.png

     

    Add Another Condition to Filter Array

    Next you'll need to adjust the Filter Array action so it only pulls the users where the Dept Group doesn't match the current Dept BU (in my case it's the Dept Role). Although it may look like the Filter Array action can only take a single condition—it can take multiple conditions when using the Advanced Editing Mode. However, you'll need to compose the expression in a text editor as it's impossible to use the advanced editor in Power Automate.

     

    Reference this section of this YT tutorial for how to add multiple conditions to a Filter Array action.

     

    In the Filter Array action, click on Edit in advanced mode.

    SharePoint List Match Step 47.png

    Highlight the expression and copy it to your clipboard.

    SharePoint List Match Step 48.png

    Paste it into a text editor

    creativeopinion_2-1703389723463.png

    Select Edit in basic mode. You'll be composing the next condition. Remove the dynamic content from the first value field.

    creativeopinion_1-1703393416897.png

     

    Insert an expression into the first value field. You need to grab the dynamic content from the Select action that is storing the Dept BU (Dept Role in my case). Reference the key that you've entered in the Select action. In my case, it's DeptRole. 

    SharePoint List Match Step 49.png

    I'll use the item() function again and enter DeptRole in between the single quotes.

    item()?['DeptRole']

    creativeopinion_2-1703393452594.png

    Change the operator to is not equal to.

    SharePoint List Match Step 51.png

    Clear the dynamic content from the second value field. 

    Insert the output from the Compose action that is storing the Dept BU value (in my case, it's the Department Role Value).

    SharePoint List Match Step 52.png

     

    Click on Edit in advanced mode and copy the expression to your clipboard. Paste it onto the second line of the text editor.

    SharePoint List Match Step 53.png

    First add a comma to separate both expressions.

    creativeopinion_3-1703390160857.png

    Then delete the @ symbol from the second line. Next wrap the entire expression with an and() function. Place your cursor after the first @ symbol and type in and with an opening parenthesis. Go to the end of the expression and add a closing parenthesis.

    creativeopinion_4-1703390244795.png

    Copy this entire expression to your clipboard and paste it into the Filter Array action (ensure you replace what is there already).

    creativeopinion_5-1703390319346.png

    Run a test. Verify the output of the Compose action storing the count of items from the Filter Array action. The number you are seeing should reflect only those items that need to be changed.

    Condition Check

    Add a Condition action. You'll use this action to check if there are any items that need to be changed before continuing on with the flow. This helps to streamline your flow as you will only run the Update Item action if there are items to update.

     

    In the first value field, insert the output from the Compose action above. Change the operator to is not equal to and enter zero into the second value field.

    creativeopinion_6-1703390442903.png

    Loop through Each Employee Item

    Add an Apply to Each action into the YES branch of the condition action. Add the Body output from the Filter Array action looping through the User list (in my case it's the Filter Array - Employee Current Dept action). Don't forget to turn on the concurrency control!

    creativeopinion_8-1703390552055.png

    The next step is optional—however I strongly recommend it. If you are new to Power Automate, it's always a good idea to confirm any dynamic content you'll be using in actions that Update or Create items before you run those actions.

    creativeopinion_1-1703366202327.png

     

    In this case, I'll be using two compose actions to store the ID and Title dynamic content. Since you are using the Apply to Each action to loop through the body of the Filter Array action, you will not be able to select dynamic content from the list—you'll need to use an expression instead.

     

    Refer to this section of a YT Tutorial I uploaded on how to get dynamic content from a Filter Array action

     

    You'll need to use the item() function and insert ID and Title into the single quote marks.

    creativeopinion_3-1703393586567.png

     

    Run a test. Verify the output. Remember that the Compose action will only have an output if the Condition is true.

    creativeopinion_4-1703366510385.png

    Update Item

    Lastly, you'll need to add an Update Item action to your flow. Ensure you are adding it inside the Apply to Each action. 

     

    In the ID field, insert the output from the appropriate Compose action above.

    creativeopinion_6-1703366581424.png

    In the Title field, insert the output from the appropriate Compose action above.

    creativeopinion_7-1703366593644.png

    Locate the dropdown for the Department BU Value (in my case it's Department Role Value). Select Enter custom value from the dropdown.

    creativeopinion_8-1703366616299.png

    Insert the output from the Compose action storing the Department BU value (in my case it's the Department Role Value).

    creativeopinion_9-1703366646719.png

    Run a test.

    creativeopinion_10-1703366706706.png

    Hope this helps!


    If I helped you solve your problem—please mark my post as a solution ✅.
    Consider giving me a 👍 if you liked my response!

    👉Watch my tutorials on YouTube
    👉Tips and Tricks on TikTok

     

     

    If you'd like to level up your Power Automate skills check out this video: Power Automate Beginner Tips and Tricks | 5 Things You Need to Know – Part 1

    I cover the following in this video tutorial:

    ✅ Power Automate Beginner Tips and Tricks

    ✅ Why use the Manual Trigger instead of an Automated Trigger

    ✅ 3 Ways a Compose Action can help you build better flows

    ✅ How to Manually Trigger a flow with a specific Date and Time

    ✅ How to return a count of items

    ✅ How to use the top count

    ✅ How to send test emails

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard