PowerApps – Display Dropdown with Month and Year (No Date)

In PowerApps, we have calendar control which works fine, but I have seen a lot of requirements to have a dropdown with only the Month Name and Year. You may know that we don’t have the option to display the Calendar without the date. So if you are looking for similar requirements, you are in the right place to learn.

UI (Month and Year)

One option is to have a table but here we are looking without any table or data source.

Power Fx Code

  • Set the OnStart of the App to

So above code produces months and years from 2000 to 2041. WHY  We defined until 2049 right. You are right but the dropdown maximum capability is 500 items.

  • Insert a dropdown and Set the Items property to

ColMonthYear

  • Select the dropdown and set the Value property to MonthYear

  • Insert a label to show the selected value from the dropdown. Set the text property of the label to

DropdownName.Selected.Month

  • Insert another label and set the text property to

DropdownName.Selected.Year

Output

Month Number and Year will display for the dropdown selection. I noticed displaying the month name on the UI and using the month number for all our calculations like filter or Sum

 

Reference (Power Fx Code)

Clear(ColMonthYear);
ForAll(
Sequence(
50,
2000
) As SourceYear,
ForAll(
Sequence(12),
Collect(
ColMonthYear,
{
Month: Value,
MonthYear: Concatenate(Last(
FirstN(
Calendar.MonthsShort(),
Value
)
).Value,” “,SourceYear.Value),
Year: SourceYear.Value
}
)
)
)

Happy Development! Reach me if you have any questions.

7 comments

  1. What if i need to show Month and Year in a dropdown from a SP list? Thus I have a date in my list and i would like to filter by month and Year.

Leave a Reply to Santhosh Cancel reply

Your email address will not be published. Required fields are marked *