Power Apps Filter Gallery By Last Week [With Various Scenarios]

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):

ColumnsData types
Request IDNumber
SubjectSingle line of text (This is a Title column, I just renamed it to Subject)
Request DateDate and time
CategoryChoice [Servers, User Workstation, Basic Software, Data Center, None]
PriorityChoice [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 Previous Week

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“.
Power Apps Filter Gallery By Last Week
  • 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.

See also  PowerApps Search User

Where,

  1. IT Help Desk‘ = SharePoint List Name
  2. Request Date‘ = SharePoint Date Column
  3. StartDate, EndDate = Scope variable names
PowerApps Filter Gallery by Last Week

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].
Power Apps Filter Gallery By Last N Weeks
  • 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,

  1. IT Help Desk‘ = SharePoint List Name
  2. Request Date‘ = SharePoint Date Column
  3. StartDate, EndDate = Scope variable names

Refer to the screenshot below.

Power Apps Filter Gallery by previous N Weeks

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.
Power Apps Filter Gallery By Last 7 Days
  • Insert a Combo box control and set its Items property as:
Items = Distinct(
    'IT Help Desk',
    'Request User'.DisplayName
)

Where,

  1. IT Help Desk‘ = SharePoint List Name
  2. Request User‘ = SharePoint People/Person Column
Power Apps Filter Gallery By Last 7 Days With a Combo box Control
  • 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,

  1. IT Help Desk‘ = SharePoint List Name
  2. Request Date‘ = SharePoint Date Column
  3. cmbReqUser = Combo box Control Name
See also  How to Filter Power Apps Data Table By Dropdown?

Refer to the image below.

Power Apps Filter Gallery By Last 7 Days With a Combo box

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.
Power Apps Filter Gallery By 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,

  1. IT Help Desk‘ = SharePoint List Name
  2. Request Date‘ = SharePoint Date Column
power apps filter gallery by this week

This is how to work with Power Apps Filter Gallery By Current Week.

Moreover, you may like some more Power Apps tutorials:

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
>