Power Apps Filter Gallery By Year [With Real Examples]

This Power Apps tutorial will guide you on working with Power Apps Filter Gallery By Year using various scenarios.

Also, we will discuss how to filter Power Apps Gallery by Last Year, how to filter Power Apps Gallery by Last N Years, and many more like:

  • Power Apps Filter Gallery By Current Year
  • Power Apps Filter Gallery By Next Year
  • Power Apps Filter Gallery By Next N Years

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 Control By Year

Now we will explore all the examples one by one.

Power Apps Filter Gallery By Year

In the first example, we will see how to work with Power Apps Filter Gallery By Year.

  • The image below represents a Power Apps Gallery Control and a Dropdown Control. When a user selects any particular year from the dropdown menu, the gallery will filter and display only those specific dropdown-selected year records.
  • For example, if I chose the year 2022, the gallery filtered and displayed all of the records for that year.
Power Apps Filter Gallery By Year
  • First, we must retrieve all the years from the SharePoint list Date column to a Power Apps Dropdown control.
  • Insert a Dropdown control and set its Items property as:
Items = Distinct(
    'IT Help Desk',
    Year('Request Date')
)

Where,

  1. IT Help Desk‘ = SharePoint List Name
  2. Request Date‘ = SharePoint Date Column

NOTE:

However, I would advise against filtering your sharepoint list directly as you would get delegation problems after 2000 rows of data.

To overcome this, apply the code below on Screen’s OnVisible property:

OnVisible = ClearCollect(ColYear, 'IT Help Desk')

Then, select the Dropdown control and set its Items property as:

Items = Distinct(ColYear, Year('Request Date'))
The above codes will avoid the Power Apps delegation issues.
Power Apps Gallery Filter By Year
  • Next, select the gallery and apply the code below on its Items property as:
Items = Filter(
    'IT Help Desk',
    Year('Request Date') = ddSelectYear.Selected.Value
)

Where,

ddSelectYear = Dropdown Control Name

PowerApps Filter Gallery By Year
  • Save, Publish, and Close the app. Play the app again and select a year from the dropdown menu. You will see the gallery will appear with only that specific year-filtered records.

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

Power Apps Filter Gallery By Last Year

Next, we will see how to filter Power Apps Gallery by last/previous year.

  • Since my current date is “8/22/2023,” the Power Apps Gallery below shows all the data from the previous year, or 2022.
Power Apps Filter Gallery By Last Year
  • To work around this, select the gallery and apply the formula below on its Items property:
Items = Filter(
    'IT Help Desk',
    'Request Date' >= Date(
        Year(Today()) - 1,
        1,
        1
    ),
    'Request Date' <= Date(
        Year(Today()) - 1,
        12,
        31
    )
)

OR

Items = With(
    {
        FirstDate: Date(
            Year(Today()) - 1,
            1,
            1
        ),
        LastDate: Date(
            Year(Today()) - 1,
            12,
            31
        )
    },
    Filter(
        'IT Help Desk',
        'Request Date' >= FirstDate,
        'Request Date' <= LastDate
    )
)

We can use any of the above formulas.

Where,

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

Refer to the below screenshot.

Power Apps Filter Gallery By Previous Year

This is how to filter Power Apps Gallery by last year.

Power Apps Filter Gallery By Last N Years

Suppose you want to filter the Power Apps Gallery by the last N Years. Then follow the example below.

  • The Power Apps Gallery contains all the records based on the last three years [from the SharePoint list], i.e., 2023, 2022, and 2021. Here, my current date is “8/22/2023,”
Power Apps Filter Gallery By Last N Years
  • To do so, select the gallery and set its Items property to the formula below:
Items = With(
    {
        FirstDate: Date(
            Year(Today()) - 3,                               // Specify this number
            Month(Today()),
            Day(Today())
        ) + 1,
        LastDate: Date(
            Year(Today()),
            Month(Today()),
            Day(Today())
        )
    },
    Filter(
        'IT Help Desk',
        'Request Date' >= FirstDate,
        'Request Date' <= LastDate
    )
)

Where,

  1. IT Help Desk‘ = SharePoint List Name
  2. Request Date‘ = SharePoint Date Column
  3. FirstDateLastDate = Scope variable names
Power Apps Filter Gallery By Previous N Years

This is how to filter Power Apps Gallery by the last N years.

Power Apps Filter Gallery By Current Year

In this scenario, we will discuss how to work with Power Apps Filter Gallery By Current Year.

  • The below Power Apps Gallery control displays all the current year records since my current date and year is “8/22/2023“.
Power Apps Filter Gallery By Current Year
  • To achieve this, write the formula below on the gallery’s Items property as:
Items = With(
    {
        FirstDate: Date(
            Year(Today()),
            1,
            1
        ),
        LastDate: Date(
            Year(Today()),
            12,
            31
        )
    },
    Filter(
        'IT Help Desk',
        'Request Date' >= FirstDate,
        'Request Date' <= LastDate
    )
)

Where,

  1. IT Help Desk‘ = SharePoint List Name
  2. Request Date‘ = SharePoint Date Column
  3. FirstDateLastDate = Scope variable Names
Power Apps Filter Gallery By This Year

This is how to work with the Power Apps filter gallery by the current year.

Power Apps Filter Gallery By Next Year

The example below will be useful if you want to filter the Power Apps Gallery by the next or upcoming year.

  • As today’s date is “8/22/2023“, the below Power Apps gallery displays all the records of the next year, i.e., 2024.
Power Apps Filter Gallery By Next Year
  • To work with this, apply the code below on the gallery’s Items property:
Items = With(
    {
        FirstDate: Date(
            Year(Today()) + 1,
            1,
            1
        ),
        LastDate: Date(
            Year(Today()) + 1,
            12,
            31
        )
    },
    Filter(
        'IT Help Desk',
        'Request Date' >= FirstDate,
        'Request Date' <= LastDate
    )
)

Where,

  1. IT Help Desk‘ = SharePoint List Name
  2. Request Date‘ = SharePoint Date Column
  3. FirstDateLastDate = Scope variable Names
Power Apps Gallery Filter By Next Year

This is how to filter the Power Apps gallery by next year.

Power Apps Filter Gallery By Next N Years

We will see how to filter Power Apps Gallery in this scenario by the next N years.

  • Since my current year is “2023“, the below Power Apps gallery filters and displays all the records of the upcoming two years [from the SharePoint List] i.e. 2024 and 2025.
Power Apps Filter Gallery By Next N Years
  • For this, set the Gallery’s Items property to the code below:
Items = With(
    {
        FirstDate: Date(
            Year(Today()),
            Month(Today()),
            Day(Today())
        ),
        LastDate: Date(
            Year(Today()) + 2,                                          // Specify this number
            Month(Today()),
            Day(Today())
        ) - 1
    },
    Filter(
        'IT Help Desk',
        'Request Date' >= FirstDate,
        'Request Date' <= LastDate
    )
)

Where,

  1. IT Help Desk‘ = SharePoint List Name
  2. Request Date‘ = SharePoint Date Column
  3. FirstDateLastDate = Scope variable Names
  4. 2 = Specify the upcoming year numbers
Power Apps Gallery Filter By Next N Years

This is how to work with Power Apps Filter Gallery By Next N Years.

Also, you may like some more Power Apps tutorials:

This Power Apps tutorial covered how to use Power Apps Filter Gallery By Year in various situations.

Additionally, we discussed how to filter Power Apps Gallery by Last Year, how to filter Power Apps Gallery by Last N Years, and many more like:

  • Power Apps Filter Gallery By Current Year
  • Power Apps Filter Gallery By Next Year
  • Power Apps Filter Gallery By Next N Years
>