With the help of different examples, this Power Apps tutorial will assist you in learning how to use the Power Apps Filter Gallery By Last Week.
Also, we will discuss how to filter the Power Apps gallery by last N Weeks, and many more like:
- Power Apps Filter Gallery By Last 7 Days With a Combo Box Control
- Power Apps Filter Gallery By Current Week
Check out: Power Apps Gallery Control Examples Download [20 Various Real Scenarios]
Set up a SharePoint List
I have used a SharePoint list IT Help Desk for all the above examples. This list has these many columns (with different data types):
Columns | Data types |
---|---|
Request ID | Number |
Subject | Single line of text (This is a Title column, I just renamed it to Subject) |
Request Date | Date and time |
Category | Choice [Servers, User Workstation, Basic Software, Data Center, None] |
Priority | Choice [Very High, High, Normal, Medium, Low, Very Low] |
Also, this list has some records, as shown in the below screenshot.
Power Apps Filter Gallery By Last Week
This example shows how to work with the Power Apps Filter Gallery By Last Week.
- The image below shows a Power Apps Gallery Control that filters all the records by the previous week since my current date is “8/21/2023“.
- To work around this, select the gallery control and apply the code below on its Items property as:
Items = Filter(
'IT Help Desk',
'Request Date' <= Today() && 'Request Date' > DateAdd(
Today(),
-7,
TimeUnit.Days
)
)
OR
Items = With(
{
StartDate: Today() - (Weekday(
Today(),
StartOfWeek.Sunday
)) - 7,
EndDate: DateAdd(
Today(),
(7 - Weekday(
Today(),
StartOfWeek.Sunday
)) - 7,
TimeUnit.Days
)
},
Filter(
'IT Help Desk',
'Request Date' > StartDate,
'Request Date' <= EndDate
)
)
We can use any of the above formulas.
Where,
- ‘IT Help Desk‘ = SharePoint List Name
- ‘Request Date‘ = SharePoint Date Column
- StartDate, EndDate = Scope variable names
This is how to filter Power Apps Gallery by last week.
Power Apps Filter Gallery By Last N Weeks
Similarly, we will see how to work with Power Apps Filter Gallery By Last N Weeks.
- Since my current date is 8/21/2023, the Power Apps Gallery in the image below only displays rows with dates older than two weeks (i.e., 14 days) [from the SharePoint List].
- To achieve this, select the Gallery control and set its Items property as:
Items = Filter(
'IT Help Desk',
'Request Date' <= Today() && 'Request Date' > DateAdd(
Today(),
-14,
TimeUnit.Days
)
)
OR
Items = With(
{
StartDate: Today() - (7*2), // Specify the last week number either 2 , 3, 4 & so on
EndDate: Today()
},
Filter(
'IT Help Desk',
'Request Date' > StartDate,
'Request Date' <= EndDate
)
)
We can use any of the above formulas.
Where,
- ‘IT Help Desk‘ = SharePoint List Name
- ‘Request Date‘ = SharePoint Date Column
- StartDate, EndDate = Scope variable names
Refer to the screenshot below.
This is all about Power Apps filter gallery by the last N weeks.
Power Apps Filter Gallery By Last 7 Days With a Combo Box Control
In this scenario, we will discuss how to filter Power Apps Gallery by the last 7 days along with a Combo box control.
- The image below represents a Power Apps Combo box Control and a Gallery Control. The gallery filters and shows the most recent seven days’ worth of records [from the SharePoint List] when a user chooses any single or multiple values from the combo box.
- Insert a Combo box control and set its Items property as:
Items = Distinct(
'IT Help Desk',
'Request User'.DisplayName
)
Where,
- ‘IT Help Desk‘ = SharePoint List Name
- ‘Request User‘ = SharePoint People/Person Column
- Next, select the Gallery control and apply the code below on its Items property:
Items = Filter(
'IT Help Desk',
'Request Date' <= Today() && 'Request Date' > DateAdd(
Today(),
-7,
TimeUnit.Days
) && 'Request User'.DisplayName in cmbReqUser.SelectedItems
)
Where,
- ‘IT Help Desk‘ = SharePoint List Name
- ‘Request Date‘ = SharePoint Date Column
- cmbReqUser = Combo box Control Name
Refer to the image below.
This is all about Power Apps Filter Gallery By Last 7 Days With a Combo Box Control.
Power Apps Filter Gallery By Current Week
If, for example, you wanted to filter the Power Apps Gallery by the current week, this example and code will guide you through the process.
- Since my current date is “8/21/2023,” the Power Apps gallery below filters and presents all the records according to the current week.
- To do so, select the Gallery control and apply the formula below on its Items property as:
Items = Filter(
'IT Help Desk',
'Request Date' >= Today() - Weekday(Today()) + 2 && 'Request Date' <= Today() + (9 - Weekday(Today()))
)
Where,
- ‘IT Help Desk‘ = SharePoint List Name
- ‘Request Date‘ = SharePoint Date Column
This is how to work with Power Apps Filter Gallery By Current Week.
Moreover, you may like some more Power Apps tutorials:
- Power Apps Filter Gallery By Date [With Examples]
- Power Apps Filter Gallery By Quarter [With Various Scenarios]
- Power Apps Filter Gallery By Last Month [With Various Examples]
- How to Filter Gallery by Current User in Power Apps
- Power Apps Sort Gallery [With 15 Useful Examples]
- Power Apps Filter Gallery By Year [With Real Examples]
- Power Apps Sequence Function [With Various Examples]
This Power Apps tutorial discussed how to filter Power Apps Filter Gallery By Last Week and how to filter Power Apps Gallery By Last N Weeks with different examples.
Additionally, we learned some more topics as:
- Power Apps Filter Gallery By Last 7 Days With a Combo Box Control
- Power Apps Filter Gallery By Current Week
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