How to Filter Power Apps Gallery By SharePoint Lookup Column?

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 NameData Type
Employee IDIt is a default single line of text
NameA single line of text
EmailA single line of text
GenderChoice
Joining DateDate and time
DepartmentLookup
Power Apps Filter Gallery By Lookup Column

This Lookup column [Department] is added from another SharePoint source list named “Departments,” which contains the fields below.

Column NameData Type
DepartmentIt is a default single line of text
ManagerPerson or Group
PowerApps Filter Gallery By Lookup Column

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:

Power Apps Filter Gallery Control By Lookup Column

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
PowerApps Filter Gallery Control By 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.

Power Apps Filter Gallery By Lookup Field

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:

How to Filter PowerApps Gallery Control By Lookup Column

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
PowerApps Filter Gallery By Lookup Field

2. Then, insert a Radio button control and set its Items property as:

Items = colEmployees
How to Filter Power Apps Gallery By Lookup Column

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
How to Filter PowerApps Gallery By Lookup Column

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.

How to Filter Power Apps Gallery Control By Lookup Column

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.

How to Filter Power Apps Gallery By Lookup Field

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
How to Filter PowerApps Gallery By Lookup Field

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
How to Filter the Power Apps Gallery By Lookup Column

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.

How to Filter Power Apps Gallery using 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:

>