web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Gallery to filter by m...
Power Apps
Answered

Gallery to filter by month

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

i have a app where gallery needs to filter depending upon the selection in the dropdowns and also need to filter by month. If the current month is July i need the gallery to filter and show the last month data's.

         Example:  if Dropdown1. Selected. Result= aa  then gallery need to filter the name of the Employees "aa" and Month would be the current month-1  to get the Last month. if current month is august i need a july month data related to the Name "aa".

 

Have a DataSource ": Employees

                        ex.png

Categories:
  • eka24 Profile Picture
    20,925 on at

    Insert 2 Dropdowns one for month and the other for Name. You can also use a combobox.

     

    On the Items property of month dropdown1 put:

    Distinct (Employee,Month)

     

    On the Items property of Name dropdown2 put:

    Distinct (Employee,Name)

     

    Then on the Items property of the Gallery;

     

    If(IsBlank (Dropdown1.Seletected.Result) Or

    IsBlank (Dropdown2.Seletected.Result),

    Employee,

    Filter (Employee, Name=Dropdown2.Selected.Result Or Month=Dropdown1.Selected.Result ))

     

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    screen.png

    No i dont want Dropdowns for Month. I used Dropdowns to list out the names . i need the gallery to update everytime depending on the current month.

    So for now we are in July month so i need a gallery to filter the previous month data of June all the time without dropdown selection.

    If i use the App in August i need the gallery to filter the July month data.

     

    Logic is to filter the gallery without using specific dropdown for months.

    it needs to calculate the current month then to subtract the current month-1 to get last month.

  • eka24 Profile Picture
    20,925 on at

    In that case use one dropdown for the Name and filter as;

     

    If(IsBlank (Dropdown1.Seletected.Result),

    Employee,

    Filter (Employee, Name=Dropdown2.Selected.Result && Month= Text( DateAdd( Today(), -1, Months ),
    "mm-yy")))

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    i use the same way that you mentioned but its shows incompatible errors and  depending on the dropdown values gallery is not filter the  previous month records. 

     

    If(IsBlank (Dropdown1.Selected.Result),

    Employee,

    Filter (Employee, Name=Dropdown1.Selected.Result && Month = Text( DateAdd( Today(), -1, Months ),
    "mm-yy")))

    ------------

    Error:

    month.png

     

     

     

  • eka24 Profile Picture
    20,925 on at

    Please show the full picture of the formula error, the complete formula with the errors

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • GarethPrisk Profile Picture
    2,828 on at

    My guess is that the Month column is in fact a date column, with custom formatting.

     

    @eka24 has good solution, but it just needs to be adjusted so the evaluation of the column is against a compatible data type (i.e. date). However, it's hard to know the format of the actual values in the column. 7/1/2020 and 7/2/2020 would both show as "7/20" with that formatting.

     

    If delegation is not a concern, you could filter the dataset with an added column. Something like:

     

    Filter (

    AddColumns(srcExcel, "appMonthDiff", DateDiff( Today(), dateColumnExcel, Months ) )

    , appMonthDiff = -1

    )

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Excel DataSource: EmployeeCol

    exact3.png

     

    My Screen:

    I have onlyone dropdowns for "' Supplier Name""

    *****I dont need dropdown for months and aslo i didnot add a month column in the Gallery.*****

    Logic is ------> Gallery needs to filter depending on the values of the dropdowns with the respective month.  Month wants to be always the previous month by calculating the current month. So i need previous month data's for all the columns mentioned in the Gallery. Current month-1 ie: August-1= July. So every time when i come in to the App and click the dropdowns it want to  filter the gallery with dropdowns selected value and the datas should display the (Current month-1 ie: August-1= July) datas.

     

    exact1.png

  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

    Do you want to filter your Gallery records based on the selected Dropdown option and respective month (current month -1)?

    Do you want to display all available records in your Gallery when you do not select any option within the Dropdown box?

     

    Based on the formula that you mentioned, I think there is something wrong with it. I have made a test on my side, please try the following formula (set the Items property of the Gallery to following) :

    Filter(
     EmployeeCol,
     If(
     IsBlank(Dropdown2_4.Selected.Result),
     true,
     'Supplier Name' = Dropdown2_4.Selected.Result && First(Split('Disposition Month', "-")).Result = Text(DateAdd(Today(), -1, Months), "[$-en-US]mmm")
     )
    )

     

    Please try above solution, hope it could solve your problem.

     

    Regards,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 226 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 191 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 167

Last 30 days Overall leaderboard