Microsoft provides two powerful controls, [Gallery and Data Table], to represent data in Power Apps. When working with Power Apps gallery control, one common requirement is filtering galleries by lookup column.
Lookup columns are used to build the relationships between different SharePoint lists or tables in a data source.
Follow this tutorial to learn how to filter Power Apps gallery by SharePoint Lookup column using different real-time scenarios.
How to Filter Power Apps Gallery By SharePoint Lookup Column
Let’s filter the Power Apps gallery control using different scenarios based on a SharePoint lookup column. Such as:
Scenario – 1:
I have a SharePoint Online list named “Employee Onboarding,” and this list contains the below fields.
Column Name | Data Type |
Employee ID | It is a default single line of text |
Name | A single line of text |
A single line of text | |
Gender | Choice |
Joining Date | Date and time |
Department | Lookup |
This Lookup column [Department] is added from another SharePoint source list named “Departments,” which contains the fields below.
Column Name | Data Type |
Department | It is a default single line of text |
Manager | Person or Group |
In Power Apps, there is a Gallery control with SharePoint list records. I would like to filter the gallery records based on the lookup column value [“IT”].
Have a look at the below screenshot for the output:
To achieve it, follow the below-mentioned steps. Such as:
1. On the Power Apps Screen, insert a Gallery control and set its Items property to the code below:
Items = Filter(
'Employee Onboarding',
Department.Value = "IT" // You can also change the Lookup field value
)
Where,
- ‘Employee Onboarding’ = SharePoint Online list
- Department = SharePoint list lookup column
2. Once your app is ready, Save, Publish, and Preview the app. The gallery control filters and displays each record from the SharePoint list based on the Lookup field value, as in the screenshot below.
Scenario-2:
In Power Apps, there is a Gallery control and a Radio button control. The Radio button control retrieves the SharePoint list look field values [Department].
Now, I want to filter and display each record from the SharePoint list records on the gallery control based on the radio button lookup value, as shown below.
Output:
To work around this, follow the below steps.
1. Select the Power Apps Screen and set its OnVisible property to the code below:
OnVisible = ClearCollect(
colEmployees,
{Value: "All"}
);
Collect(
colEmployees,
Distinct(
Departments,Title
)
)
Where,
- colEmployees = Power Apps collection name
2. Then, insert a Radio button control and set its Items property as:
Items = colEmployees
3. Insert a Gallery control and set its Items property as:
Items = If(
Radio_Departments.Selected.Value = "All",
'Employee Onboarding',
Filter(
'Employee Onboarding',
Department.Value = Radio_Departments.Selected.Value
)
)
Where,
- Radio_Departments = Power Apps Radio button name
4. Save, Publish, Reload, Preview the app. The gallery control filters and displays the SharePoint list records based on the Radio button Lookup selected value like below.
Scenario-3:
Power Apps has two gallery controls. The first, [gal_Departments], retrieves the SharePoint Lookup field values.
Whenever the user selects a value from the first gallery, the second gallery filters and displays selected lookup field records. The output is shown in the screenshot below.
To do so, follow the below steps. Such as:
1. On the Power Apps Screen -> Insert a Gallery control [Make it the gallery layout is “Title”] and set its Items property as:
Items = Departments
Where,
- Departments = SharePoint destination list
2. Then, insert another gallery control and set its Items property to the code below.
Items = Filter(
'Employee Onboarding',
Department.Value = gal_Depatments.Selected.Title
)
Where,
- gal_Depatments = Power Apps gallery name
3. Save, Publish, and Preview the app. When the user selects any value from the first gallery control, the second gallery control filters and displays selected lookup field records, as shown below.
This way you can filter the Power Apps gallery control by Lookup column.
I hope this tutorial is helpful. You can follow the above three different and useful scenarios and easily filter a Power Apps gallery control by the Lookup column.
Also, you may like some more Power Apps articles:
- Filter Power Apps Gallery By Multiple Dropdowns
- Power Apps Filter Gallery By Date
- Filter Power Apps Gallery by Current User
- Create Hyperlink Button in Power Apps
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com