cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AlexandruChiser
Frequent Visitor

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

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!

3 REPLIES 3
AlexandruChiser
Frequent Visitor

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... 

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

@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

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (2,119)