“I have two SharePoint lists, list A and list B, how to get all “lookup” data from list B that link to list A using Power Automate?”
Lookup to another SharePoint list in Power Automate is implemented using the ‘Get items’ action. It’s a similar process as when you implement lookup on list of approvers for approval processes. The only difference is in the filter you use. In the previous post it was a user, here it’s any column with unique data. It can be text or number, but for connected items it must have the same value in both lists. That column will be used in the ‘Filter Query’.
Implement the lookup
First step is to add the ‘Get items’ action to your flow. This action should lead to the 2nd list. 1st list is the one where the flow is running, 2nd list contains the lookup data.
This is also where you define the ‘lookup’ functionality adding the ‘Filter Query’. Telling the action to return only items where the unique column has the same value. In an example below, it’s the ‘Title’ column which is unique.
Note: always use the column internal name in the Filter Query.
Output of this action will be ‘value’ dynamic content. It’s an array with all items from the 2nd list that fit the filter.
Process the lookup result
As already stated, the output from the ‘Get items’ action will be an array. And to get any value from the array, Power Automate will automatically add ‘Apply to each’. Keep in mind that everything inside the ‘Apply to each’ will run for each item returned.
If there’s just 1 item, you can skip the next step and process it directly.
Process the lookup result with multiple items
But if there’re e.g. 5 items, the ‘Apply to each’ will run 5 times. That being said, before using the lookup data in a task/email/anywhere else, you should preprocess it. You don’t want to send e.g. 5 emails, you want 1 email with data from 5 items. Therefore, you should convert it from an array into a single string variable in the loop. The example below will append data in ‘Rating’ column from multiple items into a single variable.
That might be the only action you need inside the ‘Apply to each’. Once you append data from all the items into a variable, you can use the variable wherever you need. Without any additional loops.
Note: you could use also the ‘Select’ action instead of the loop.
Summary
Building a lookup to another SharePoint list has three equally important parts. You must ‘Get items’ first, and then process them accordingly. If you skip the ‘Get items’ action then there’re no lookup items. If you skip the ‘Filter Query’ on the unique column, you’ll get all items from the 2nd list. And if you try to use the ‘lookup’ data directly, without appending into a variable, you’ll get many repeated actions (emails, tasks…).
And if end up with the other problem, that there’re 0 items returned, try to check my previous post on common mistakes using the Filter Query.
At the first step, when I put in the Filter query: Detection_system (the main table) eq ‘Title’ (the lookup table) , it automatically converts the whole step from Get Items from Sharepoint -> Apply to each and put that Get Items inside.
Hello kole,
your Title input probably comes from an array, e.g. from another Apply to each, take a look on this article: https://tomriha.com/stop-power-automate-flow-from-adding-apply-to-each-automatically/
Hi Kole,
I have a situation where the majority of users who will be initiating the flow do not have a M365 license. Instead, there will be a general licensed used to submit the app for approvals. I need to use get items to return the users manager name stored in another list to assign the destination email address for the request. List “A” contains the employee’s name along with their managers name (managers have a M365 license). List “B” will contain the vacation request details along with the employee’s name. How can I use the employee’s name from list “B” and return the managers name from list “A” as a value to be used in the approval process? I’m open to other ideas as well for completing this task.