Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Triggers
  • Application specific solutions
    • Dataverse
    • Excel
    • Forms
    • Planner
    • Outlook
    • SharePoint
    • Teams
  • Resources
  • Get help with flow
Menu

How to lookup data in a SharePoint list in Power Automate

Posted on December 2, 2020February 9, 2022 by Tom

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

Power Automate lookup sharepoint list

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.


Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

1 thought on “How to lookup data in a SharePoint list in Power Automate”

  1. Pingback: How to get data from sharepoint list in power automate? - To Code

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Do you know what to do, but not how to do it?

Get The Ultimate Power Automate expressions cheat sheet and translate your thoughts into flows with ease!


NEW! Master the HTTP requests to SharePoint with a new cheat sheet!

Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Hello and welcome!

My name is Tom and I'm a business process automation consultant and Microsoft MVP living in the Czech Republic. I’ve been working with Microsoft technologies for almost 10 years, currently using mainly Power Automate, SharePoint, Teams, and the other M365 tools.

I believe that everyone can automate part of their work with the Power Automate platform. You can achieve a lot by "clicking" the flows in the designer, but you can achieve much more if you add a bit of coding knowledge. And that's what this blog is about.

To make the step from no-code Power Automate flows to low-code flows: using basic coding knowledge to build more complex yet more efficient flows to automate more of your daily tasks.

  • Use Power Automate to forward Outlook events upon registrationJanuary 29, 2023
  • Why the condition is false for the same numbers (Power Automate)January 25, 2023
  • How to forward event invitation to other calendar (Power Automate)January 22, 2023
  • Run ‘For selected item’ flow from non-default environment (Power Automate)January 18, 2023
  • Hide button in SharePoint list after Power Automate flow startedJanuary 15, 2023

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

©2023 Let's POWER Automate | Theme by SuperbThemes