Filter Gallery by Dropdown List in Canvas Apps
Introduction
Filtering data is one of the most common requirements in Power Apps Canvas Apps. Dropdown controls provide an easy way for users to filter gallery records dynamically based on selected values.
In this article, you'll learn how to filter a gallery using a dropdown control, improve user experience, and create responsive applications with Power Apps.
Why Use Dropdown Filters in Canvas Apps?
Dropdown filters help users:
- Quickly find relevant records.
- Improve application usability.
- Reduce manual searching.
- Display only required information.
- Enhance performance by limiting displayed records.
Prerequisites
Before starting, ensure you have:
- Power Apps Canvas App.
- Data source (Dataverse, SharePoint, SQL, Excel, etc.).
- Gallery control.
- Dropdown control.
Sample Scenario
Suppose you have an Employee table with the following columns:
| Employee Name | Department |
|---|---|
| John Smith | HR |
| David Miller | IT |
| Sarah Wilson | Finance |
| Michael Brown | IT |
Requirement:
Filter employees based on the selected department.
Step 1: Add a Dropdown Control
Insert a Dropdown control.
Navigate to:
Insert → Input → Dropdown
Rename the control:
drpDepartment
Step 2: Populate Dropdown Values
Set the Items property:
Distinct(Employees, Department)
This displays unique department values.
Step 3: Add a Gallery Control
Insert a Vertical Gallery.
Navigate to:
Insert → Gallery → Vertical
Connect the gallery to your data source.
Example:
Employees
Step 4: Apply Filter to Gallery
Set the Gallery Items property:
Filter(
Employees,
Department = drpDepartment.Selected.Value
)
Result
When a department is selected, only matching records appear in the gallery.
Allow "All Records" Option
Sometimes users need to view all records.
Set Dropdown Items:
["All"] & Distinct(Employees, Department)
Update Gallery Items:
If(
drpDepartment.Selected.Value = "All",
Employees,
Filter(
Employees,
Department = drpDepartment.Selected.Value
)
)
Result
- All → Shows all employees.
- HR → Shows HR employees.
- IT → Shows IT employees.
- Finance → Shows Finance employees.
Filtering SharePoint List Data
Example SharePoint List:
| Title | Status |
|---|---|
| Request 1 | Open |
| Request 2 | Closed |
| Request 3 | Open |
Dropdown Items:
Distinct(Requests, Status)
Gallery Items:
Filter(
Requests,
Status = drpStatus.Selected.Value
)
Filtering Dataverse Records
Example Dataverse Table:
Accounts
Dropdown Items:
Distinct(Accounts, Industry)
Gallery Items:
Filter(
Accounts,
Industry = drpIndustry.Selected.Value
)
Multi-Condition Filtering
Example: Filter by Department and Location.
Filter(
Employees,
Department = drpDepartment.Selected.Value &&
Location = drpLocation.Selected.Value
)
Result
Only records matching both filters are displayed.
Search and Dropdown Combination
Combine Search and Dropdown.
Filter(
Employees,
Department = drpDepartment.Selected.Value &&
StartsWith(
EmployeeName,
txtSearch.Text
)
)
Result
Users can search and filter simultaneously.
Real-Time Business Scenario
Requirement
A company wants users to filter customer records by industry.
Solution
- Create Industry Dropdown.
- Populate unique industries.
- Apply Filter function to Gallery.
Formula
Filter(
Accounts,
Industry = drpIndustry.Selected.Value
)
Result
Users instantly view customers belonging to the selected industry.
Common Errors
No Records Displayed
Cause:
Incorrect column reference.
Solution:
Verify field names and dropdown values.
Invalid Property Error
Cause:
Using incorrect selected property.
Incorrect:
drpDepartment.SelectedText.Value
Correct:
drpDepartment.Selected.Value
Delegation Warning
Cause:
Large data source.
Solution:
Use delegable functions whenever possible.
Example:
Filter()