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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Month Year Dropdown
Power Apps
Unanswered

Month Year Dropdown

(1) ShareShare
ReportReport
Posted on by 6
Hello everyone,
 
I am hoping someone might be able to assist me. I have done a lot of research and thought I would manage to figure this out on my own but I am very much struggling.
 
I am trying to use a single dropdown component which displays the current ‘Month Year’ formatted like ‘July 2024’ without the day and the previous ‘Months Years’ back to a specified date in the code.
 
I am then hoping to use the selected option to filter a Gallery from this selection against the date column. 
 
Thank you very much for any help you can give.
 
Jonathan
Categories:
I have the same question (0)
  • level36 Profile Picture
    77 on at
    Hi,
     
    For this I would use a ComboBox for this solution, since that will let you store both the Date and the MonthYear Value.
     
    Set the Items of the ComboBox to
     
    ForAll(Sequence(12) As Month,
        {
            MonthYear: Text(Date(Year(Now()) + RoundDown(Month.Value / 12, 0), Month(Now()) + Month.Value, 1), "mmmm yyyy"),
            Date: Date(Year(Now()) + RoundDown(Month.Value / 12, 0), Month(Now()) + Month.Value, 1)
        }
    )

    You can change the number of months to go ahead by updating the number in the Sequence Function.
    Right now it is set to go 12 months ahead.
     
    Then filter your gallery using
     
    Filter(DataSource, DataSrouceDate >= MonthYearComboBox.Selected.Date)
     
    This will return any records in or after the month that was selected.
  • Suggested answer
    venturemavenwill Profile Picture
    1,189 Super User 2025 Season 2 on at
    I've created the following example for this use case. This is the sample collection that I will be using:

    ClearCollect(RandomDatesCollection,
        { RandomDate: Date(2025, 1, 27), Label: "Event A" },
        { RandomDate: Date(2025, 6, 13), Label: "Event B" },
        { RandomDate: Date(2025, 3, 30), Label: "Event C" },
        { RandomDate: Date(2025, 4, 23), Label: "Event D" },
        { RandomDate: Date(2024, 8, 6), Label: "Event E" },
        { RandomDate: Date(2025, 2, 8), Label: "Event F" },
        { RandomDate: Date(2025, 6, 13), Label: "Event G" },
        { RandomDate: Date(2024, 8, 4), Label: "Event H" },
        { RandomDate: Date(2025, 7, 4), Label: "Event I" },
        { RandomDate: Date(2024, 10, 14), Label: "Event J" },
        { RandomDate: Date(2024, 11, 13), Label: "Event K" },
        { RandomDate: Date(2025, 7, 22), Label: "Event L" },
        { RandomDate: Date(2025, 4, 7), Label: "Event M" },
        { RandomDate: Date(2025, 5, 27), Label: "Event N" },
        { RandomDate: Date(2025, 4, 17), Label: "Event O" },
        { RandomDate: Date(2025, 7, 21), Label: "Event P" },
        { RandomDate: Date(2024, 8, 26), Label: "Event Q" },
        { RandomDate: Date(2025, 4, 9), Label: "Event R" },
        { RandomDate: Date(2025, 2, 22), Label: "Event S" },
        { RandomDate: Date(2025, 3, 26), Label: "Event T" }
    )
    First I create a dropdown that populates the year and month similar to previously described (but using DateAdd to better handle the transition between the years. 

    ForAll(
        Sequence(12) As Month,
        {
            MonthYear: Text(DateAdd(Date(Year(Now()), Month(Now()), 1), Month.Value - 1, TimeUnit.Months), "mmmm yyyy"),
            Date: DateAdd(Date(Year(Now()), Month(Now()), 1), Month.Value - 1, TimeUnit.Months)
        }
    )
    In the items parameter of the gallery, I create a new column reference date, set it to the first day of the month of the parameter RandomDate, and bind it to the selected dropdown value like this:

    Filter(
        AddColumns(
            RandomDatesCollection,
            'Filter Date', Date(Year(RandomDate),Month(RandomDate),1)
        ),
        'Filter Date' = Dropdown1.Selected.Date
    )
    Now, whenever I select a month and year, all the events of that months are displayed in the gallery.


    Let me know if this helps
  • CU30071550-2 Profile Picture
    6 on at
    Thank you both very much for your very helpful responses!
     
    Both are very close to what I am hoping to achieve. I am very close now.
     
    I have two further questions if I may.
     
    1)     Is it possible instead of the list of 'Months Years' going forwards twelve months as the sequence allows for example JUNE 2024, JULY 2024, AUGUST 2024 etc ... , to have it go backwards instead, for example JUNE 2024, MAY 2024, APRIL 2024 etc .... The current month being the default selected. I am struggling to wrap my head round the code. 
     
    2)    And only if possible, instead of simply going back 12 months from this month, can it instead be programmed go back until a specified month year.
     
    Such as 'MAY 2023' and no further?
     
    Thank you so much again both for your help with this.
     
    Jonathan
  • Suggested answer
    level36 Profile Picture
    77 on at
    Hi,
     
    I've modified the formula to count backwards to a specific date from the current date. The starting date can be changed by modifying the Date() in the Sequence call. I've used your example of May 2023 in the code below.
     
    ForAll(Sequence(DateDiff(Date(2023, 5, 1), Now(), TimeUnit.Months) + 1, 0, -1) As Month,
        {
            MonthYear: Text(Date(Year(Now()) + RoundDown(Month.Value / 12, 0), Month(Now()) + Month.Value, 1), "mmmm yyyy"),
            Date: Date(Year(Now()) + RoundDown(Month.Value / 12, 0), Month(Now()) + Month.Value, 1)
        }
    )
    
    If you will be filtering a DataSource for any date on or after the selected date (get items from selected date to now) you could use the following filter. Remove the second filter condition if you want to include future dates.   
    Filter(DataSource, DataSrouceDate >= MonthYearComboBox.Selected.Date, DateSouceData <= Now())
     
  • venturemavenwill Profile Picture
    1,189 Super User 2025 Season 2 on at
    @ CU30071550-2

    I think I understand what you are trying to do now. So basically what you are trying to achieve is 
     
    1. Define a date range where the "From" date is defined by you in the code, and the "To" Date is defined by the dropdown
     
    2. Based on the selection, the To date will always change but the "From" date remains the same,

    is that correct?

    If so, do you plan to set the "From" date statically in your code, or does this value come from somewhere?

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard