Power Apps Filter Gallery By Month [With Various Examples]

This Microsoft Power Apps tutorial explains everything about the Power Apps filter gallery by Month.

Here, I will discuss how to filter a Power Apps gallery by the current month and how to filter a Power Apps gallery by next month.

Moreover, we will see the topics below:

  • Filter Power Apps gallery by next ‘N’ months
  • Filter Power Apps gallery by Previous month
  • How to filter a Power Apps gallery by previous ‘N’ months

Power Apps Filter Gallery By Month [Current Month]

I will show you how to filter a Power Apps gallery by the current month.

Example:

  • I have a SharePoint Online List named “Training Courses Demos“. This list contains the below fields.
Column NameData Type
Course NameThis is a Title column with a single line of text. I just renamed it to “Course Name”
DescriptionMultiple lines of text
Demo Start DateDate and time
Demo End DateDate and time
Power Apps Filter Gallery By Month
  • In Power Apps, there is a Gallery control. This gallery displays each record from the SharePoint list based on the current month.
Power Apps Filter Gallery By Current Month

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

Power Apps Gallery Filter By Current Month
  • Insert a Gallery control [gal_CurrentMonthDemos] and set its Items property to the code below.
Items = With(
    {
        StartDate: Date(
            Year(Today()),
            Month(Today()),
            1
        ),
        EndDate: Date(
            Year(Today()),
            Month(Today())+1,
            1
        )-1
    },
    Filter(
        'Training Courses Demos',
        'Demo Start Date' >= StartDate,
        'Demo End 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. Year(Today()) = This function returns the year component of a Date/Time value
  5. Month(Today()) = This function returns the month component of a Date/Time value
  6. ‘Training Courses Demos’ = SharePoint Online List
  7. ‘Demo Start Date’, ‘Demo End Date’ = SharePoint date fields columns
How to Filter Power Apps Gallery By Current Month
  • SavePublish, and Preview the app. The gallery will display the filtered records, i.e., [Current Month Records], as in the screenshot below.
Power Apps Filter Gallery By This Month

This is how to filter a Power Apps gallery by the current month.

Power Apps Filter Gallery By Next Month

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

Example:

  • I will also take the same SharePoint Online list [Training Courses Demos] for this example.
  • In Power Apps, there is a Horizontal gallery control. This gallery displays each record from the SharePoint list based on the next or upcoming month.

Refer to the below image:

Power Apps Filter Gallery By Next Month

To work around this example, follow the below steps.

  • On the Power Apps Screen -> Insert a Gallery control and set its Items property as:
Items = With(
    {
        StartDate: Date(
            Year(Today()),
            Month(Today())+1,
            1
        ),
        EndDate: Date(
            Year(Today()),
            Month(Today())+2,
            1
        )-1
    },
    Filter(
        'Training Courses Demos',
        'Demo Start Date' >= StartDate,
       'Demo End Date' <= EndDate
    )
)

Where,

  1. Month(Today())+1 = Power Apps Month() helps to get the current month, and “+1” is for next month
Power Apps Filter Gallery By Upcoming Month
  • Save, Publish, and Preview the app. The gallery will display the filtered records, i.e., [Next Month Records], as shown below.
Power Apps Gallery Filter By Next Month

This is how we can filter a Power Apps gallery by the next/upcoming month.

Power Apps Filter Gallery By Next ‘N’ Months

Let’s see how to filter a Power Apps gallery by the next ‘N’ months.

Example:

  • I will take the same SharePoint Online list [Training Courses Demos] 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 two months.
Power Apps Filter Gallery By Next 'N' Months

To do so, follow the below-mentioned steps. Such as:

  • On the Power Apps Screen -> Insert a Gallery control and set its Items property to the code below.
Items = With(
    {
        StartDate: Date(
            Year(Today()),
            Month(Today()),
            Day(Today())
        ),
        EndDate: Date(
            Year(Today()),
            Month(Today())+2,
            Day(Today())
        )-1
    },
    Filter(
       'Training Courses Demos' ,
        'Demo Start Date' >= StartDate,
        'Demo End Date' <= EndDate
    )
)

Where,

  1. Month(Today())+2 =  This function returns the month component of a Date/Time value, and ‘2’ is the number of next months // You can change the number of months

Refer to the below screenshot:

How to Filter Power Apps Gallery By Next 'N' Months
  • Save, Publish, and Preview the app. The gallery will display the filtered records, i.e., [Next 2 Months Records] like below.
Power Apps Gallery Filter By Next 'N' Months

This is all about the Power Apps filter gallery by the next/upcoming ‘N’ months.

Power Apps Filter Gallery By Previous Month

Similarly, here we will discuss how to filter a Power Apps gallery by the previous month.

Example:

  • I will take the same SharePoint Online list [Training Courses Demos] for this example.
  • In Power Apps, there is a Horizontal gallery control. This gallery displays each record from the SharePoint list based on the last or previous month.
Power Apps Filter Gallery By Previous Month

To achieve this example, follow the below steps.

  • On the Power Apps Screen -> Insert a Gallery control and set its Items property as:
Items = With(
    {
        StartDate: Date(
            Year(Today()),
            Month(Today())-1
            ,1
        ),
        EndDate: Date(
            Year(Today()),
            Month(Today())
            ,1
        )-1
    },
    Filter(
       'Training Courses Demos' ,
        'Demo Start Date' >= StartDate,
        'Demo End Date' <= EndDate
    )
)

Where,

  1. Month(Today())-1 =  This function returns the month component of a Date/Time value, and ‘1’ is used for the previous/last month
Power Apps Gallery Filter By Previous Month
  • Save, Publish, and Preview the app. This gallery will display the filtered records, i.e., [Last 2 Months Records], as in the screenshot below.
Power Apps Filter Gallery By Last Month

This is how to filter a Power Apps gallery by previous/last month.

Power Apps Filter Gallery By Previous ‘N’ Months

Last, we will see how to filter a Power Apps gallery by previous ‘N’ months.

Example:

  • I will also take the same SharePoint Online list [Training Courses Demos] for this example.
  • In Power Apps, there is Vertical gallery control. This gallery displays each record from the SharePoint list based on the last or previous three months.

Refer to the below image:

Power Apps Filter Gallery By Previous 'N' Months

To work around this example, follow the below steps. Such as:

  • On the Power Apps Screen -> Insert a Gallery control and set its Items property as:
Items = ith(
    {
        StartDate: Date(
            Year(Today()),
            Month(Today())-3,
            Day(Today())
        )+1,
        EndDate: Date(
            Year(Today()),
            Month(Today()),
            Day(Today())
        )
    },
    Filter(
       'Training Courses Demos' ,
      'Demo Start Date'  >= StartDate,
        'Demo End Date'  <= EndDate
    )
)

Where,

  1. Month(Today())-3 = This function returns the month component of a Date/Time value, and ‘3’ is the number of previous months // You can change the number of months
Power Apps Gallery Filter By Previous 'N' Months
  • Save, Publish, and Preview the app. This gallery will display the filtered records, i.e., [Last 3 Months Records], as shown below.
Power Apps Filter Gallery By Last 'N' Months

This is how to filter a Power Apps gallery by previous/last ‘N’ months.

Conclusion

This Microsoft Power Apps tutorial taught us all about the Power Apps filter gallery by month.

Here, I explained how to filter a Power Apps gallery by the current month and how to filter a Power Apps gallery by next month.

Also, we discussed the Power Apps filter galley by the next/upcoming ‘N’ months and how to filter a Power Apps gallery by the previous month. Last, we covered how to filter a Power Apps gallery by previous/last ‘N’ months.

Additionally, you may like some more Power Apps tutorials: