One of my clients requested me to build a leave management application in Power Apps. That application has a screen displaying all employee leave requests for Approver people, such as the HR manager. Here, I got a requirement to filter the gallery based on Employee names and dates.
In this article, I will explain how to apply multiple filters on the Power Apps gallery.
Apply Multiple Filters On Power Apps Gallery
In the example below, you can see both employee names and dates filter the gallery. Here, I took employee names from Microsoft 365 users.
Here is the SharePoint list named Employee Leave Requests used for the above Power Apps gallery.
To achieve this, follow the steps below!
1. Connect Power Apps with SharePoint list. Then, add a Combo box control and put the formula below in its Items property.
Office365Users.SearchUser({searchTerm:cmb_EmpName.SearchText}).DisplayName
Here, cmb_EmpName is the combo box control name. This formula displays all Microsoft 365 users’ display names in combo box control. You can easily search for the employee’s name here.
2. Add a Power Apps Date Picker control and a Reload Icon. In the OnSelect property of the reload icon, provide the formula below.
Reset(dtp_StartDate)
We use this formula to filter the Power Apps gallery to reset the date picker control.
3. Add a Power Apps gallery control and provide the formula below in its Items property:
If(
!IsBlank(dtp_StartDate.SelectedDate) && !IsBlank(cmb_EmpName.Selected),
Filter(
'Employee Leave Requests',
'Employee Name' = cmb_EmpName.Selected.DisplayName &&
'Start Date' = dtp_StartDate.SelectedDate
),
!IsBlank(dtp_StartDate.SelectedDate),
Filter(
'Employee Leave Requests',
'Start Date' = dtp_StartDate.SelectedDate
),
!IsBlank(cmb_EmpName.Selected),
Filter(
'Employee Leave Requests',
'Employee Name' = cmb_EmpName.Selected.DisplayName
),
'Employee Leave Requests'
)
Here,
- dtp_StartDate = Date picker control name.
- cmb_EmpName = Combo box control name.
- Employee Leave Requests = SharePoint list name.
This formula filters the Power Apps gallery based on three conditions.
- The gallery will be filtered based on the combo box and date picker selection.
- Based on the combo box selection.
- Based on the date picker selection.
- If we don’t select any option by default, it will display all employee leave requests.
Save the changes and preview the app once. While selecting the employee name in the combo box, you can see that it filters the Power Apps gallery. If we select only the date, the gallery will also be filtered based on that selection. If we choose both the combo box and the date value, the gallery will be filtered based on two values.
I hope you understand how to apply multiple filters on the Power Apps gallery.
Additionally, you may like some more Power Apps articles:
- Show/Hide Button Based on Condition in Power Apps
- Show/Hide Password in Power Apps Login Page
- Replace Position of First Name and Last Name in Power Apps
- Power Apps Left Navigation Component
- Generate and Download PDFs From 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