Power Apps Filter Gallery By Days [Current, Next, Next N, Previous, Previous N]

In this Power Apps tutorial, I will explain all about the Power Apps filter gallery by days. Then, I will show you how to filter the Power Apps gallery by the current day.

Also, we will discuss the Power Apps filter gallery by the next day. Then, filter the Power Apps gallery by the next ‘N’ days.

Moreover, we will cover how to filter the Power Apps gallery by the previous day and filter the Power Apps gallery by the previous ‘N’ days.

Power Apps Filter Gallery By Days [Current Day]

We will see how to work with the Power Apps filter gallery by Today’s Date by taking a simple scenario.

Example:

  • I have a SharePoint Online List named “Order Details“. This list contains the below fields.
Column NameData Type
Product NameThis is a Title column with a single line of text. I just renamed it to Product Name
Order DateDate and Time
PriceNumber
Power Apps Filter Gallery By Day
  • In Power Apps, there is a Gallery control. This gallery displays each record from the SharePoint list based on today’s records, as in the screenshot below.
Power Apps Filter Gallery By Today's Date

To achieve the above example, follow the below-mentioned steps. Such as:

  • Open your Power Apps with respective Microsoft credentials -> Create a Power Apps blank canvas app -> Connect the SharePoint list to the app. Once you connect, it will look like the screenshot below.
Power Apps Filter Gallery By Current Date
  • Insert a Gallery control [gal_ProductOrders] and set its Items property as:
Items = With(
    {
        StartDate: Today(),
        EndDate: Today() + 1
    },
    Filter(
        'Order Details',
        'Order Date' >= StartDate,
        'Order Date' < EndDate
    )
)

Where,

  1. With() = This function can help us to evaluate a formula for a single record
  2. StartDate, EndDate = Power Apps scope variables
  3. Today() = Power Apps Today() helps to get the current date
  4. ‘Order Details’ = SharePoint Online List
  5. ‘Order Date’ = SharePoint date field
Power Apps Gallery Filter By Current Date
  • Save, Publish, and Preview the app. The gallery will display the filtered records, i.e., [Today’s Records], as in the screenshot below.
Power Apps Gallery Filter By Day

This is how to filter a Power Apps gallery by Today’s Date.

Power Apps Filter Gallery By Next Day [Tomorrow]

Next, we will see how to filter a Power Apps gallery by the next day.

Example:

  • I will also take the same SharePoint Online list [Order Details] for this example.
  • In Power Apps, there is a Vertical Gallery control. This gallery filters and displays each record from the SharePoint list based on the next or tomorrow’s date.

Refer to the below image:

Power Apps Filter Gallery By Next Day

To work around this example, follow the below steps.

  • On the Power Apps Screen -> Insert a Gallery control and set its Items property to the code below.
Items = With(
    {
        StartDate: Today(),
        EndDate: Today() + 1
    },
    Filter(
        'Order Details',
        'Order Date' > StartDate,
        'Order Date' <= EndDate
    )
)

Where,

  1. StartDate, EndDate = Power Apps Scope Variables
  2. Today() + 1 = Tomorrow’s Date
Power Apps Filter Gallery By Tomorrow's Date
  • Save, Publish, and Preview the app. The gallery will display the filtered records, i.e., [Tomorrow’s Records], as in the screenshot below.
Power Apps Gallery Filter By Tomorrow's Date

This is how to filter the Power Apps gallery by Tomorrow’s date.

Power Apps Filter Gallery By Next ‘N’ Days

Let’s discuss how to filter the Power Apps gallery by the next ‘N’ Days.

Example:

  • I will take the same above SharePoint Online list [Order Details] for this example.
  • In Power Apps, there is a Vertical Gallery control. This gallery filters and displays each record from the SharePoint list based on the next/upcoming three days.

Refer to the below screenshot:

Power Apps Gallery Filter By Next 'N' Days

To do so, follow the below steps.

  • On the Power Apps Screen -> Insert a Gallery control and set its Items property as:
Items = With(
    {
        StartDate: Today(),
        EndDate: Today() + 3         // You can change this number of days
    },
    Filter(
        colOrders,
        'Order Date' >= StartDate,
        'Order Date' <= EndDate
    )
)

Where,

  1. Today() + 3 = Today() function helps to get the current date. And 3 is the number of weekdays.
How to Filter Power Apps Gallery By Next 'N' Days
  • Save, Publish, and Preview the app. The gallery will display the filtered records, i.e., [Next three Day’s Records] as shown below.
How to Filter a Power Apps Gallery By Next 'N' Days

This is all about the Power Apps filter gallery by the next ‘N’ Days.

Power Apps Filter Gallery By Yesterday [Previous Day]

Here, we will see how to filter a Power Apps gallery by Yesterday’s Date by taking a simple scenario.

Example:

  • I will take the same above SharePoint Online list [Order Details] for this example.
  • In Power Apps, there is a Vertical Gallery control. This gallery displays each record from the SharePoint list based on the yesterday or previous day.

Refer to the below image:

Power Apps Filter Gallery By Yesterday

To work around this example, follow the below-mentioned steps.

  • Open the Power Apps Screen -> Insert a Gallery control and set its Items property as:
Items = With(
    {
        StartDate: Today()-1,
        EndDate: Today()
    },
    Filter(
        'Order Details',
        'Order Date' >= StartDate,
        'Order Date' < EndDate
    )
)

Where,

  1. Today()-1 = Yesterday’s Date
Power Apps Filter Gallery By Yesterday's Date
  • Save, Publish, and Preview the app. The gallery will display the filtered records, i.e., [Yesterday’s Records] as in the screenshot below.
Power Apps Filter Gallery By Previous Day

This is how to filter a Power Apps gallery by Yesterday’s Date.

Power Apps Filter Gallery By Previous ‘N’ Days

Finally, we will discuss filtering a Power Apps gallery by Previous ‘N’ Days.

Example:

  • I will also take the same SharePoint Online list [Orders Details] for this example.
  • In Power Apps, there is a Gallery control. This gallery displays each record from the SharePoint list based on the last/previous four days.

Refer to the below screenshot:

Power Apps Filter Gallery By Previous 'N' Days

To achieve this, follow the below steps.

  • On the Power Apps Screen -> Insert a Gallery control and set its Items property to the code below.
Items = Filter(
    'Order Details',
    'Order Date' >= DateAdd(
        Today(),
        -4,                                      // You can also change the number of days
        TimeUnit.Days
    )
)

Where,

  1. ‘Order Details’ = SharePoint Online List
  2. DateAdd() = This function adds a number of units to a Date/Time column
  3. -4 = Number of Previous Days
Power Apps Filter Gallery By Before 'N' Days
  • Save, Publish, and Preview the app. The gallery will display the filtered records, i.e., [Previous four Day’s Records] as shown below.
Power Apps Gallery Filter By Previous 'N' Days

This is how to filter a Power Apps gallery by Previous ‘N’ Days.

Conclusion

This Microsoft Power Apps tutorial taught us all about the Power Apps filter gallery by day. Here, I explained how to filter the Power Apps gallery by the current day and how to filter the Power Apps gallery by the next day.

Also, we discussed the Power Apps filter gallery by the next ‘N’ days and how to filter a Power Apps gallery by the previous day. We last covered how to filter the Power Apps gallery by the previous ‘N’ days.

Also, you may like some more Power Apps tutorials: