How to Filter Power Apps Gallery to Show Only Yesterday’s Date

How to Filter Power Apps Gallery to Show Only Yesterday’s Date

 

How to Filter Power Apps Gallery to Show Only Yesterday’s Date

Introduction:
In the realm of app development using Power Apps, developers often encounter the need to filter data based on specific date criteria. One common requirement is to display data from the previous day. Wondering how to filter a gallery in Power Apps to showcase only yesterday’s date? This guide illustrates a simple method using a SharePoint list as an example.

Let’s consider a scenario where you have a SharePoint list named “Date Records” which contains sequential days from January 1, 2018, to December 31, 2024.

Data Structure:

Title DateRecord
Monday, January 1, 2018 1/1/2018
Tuesday, January 2, 2018 1/2/2018
Tuesday, June 15, 2023 6/15/2023
Tuesday, December 31, 2024 12/31/2024

Filtering Logic:

To achieve the desired filtering, implement the following logic in the “Items” property of your gallery component:

With(
    {
        PrevDay: Today()-1,
        CurrentDay: Today()
    },
    Filter(
        'Date Records',
        DateRecord >= PrevDay,
        DateRecord < CurrentDay
    )
)

 Result:

With this logic, the gallery will display only the rows corresponding to yesterday’s date. For instance, if today is June 16, 2023, the gallery will show:

Title DateRecord
Tuesday, June 15, 2023 6/15/2023

Reference:

  1. With function in Power Apps
  2. Filter, Search, and LookUp functions in Power Apps

Conclusion:
Power Apps provides a dynamic platform for developers to cater to specific data visualization needs. Filtering a gallery by yesterday’s date is just one of the countless functionalities that can be achieved with precise logic and understanding of the platform. Implementing such features enhances user experience and brings efficiency to app interactions.

If you want to learn more about the Power Apps, feel free to explore our other informative articles and tutorials.

About The Author