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 Month Name and Year. You may know that we don’t have the option to display Calendar without the date. So if you are looking for similar requirements then 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 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. 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 any questions.

Leave a Reply

Your email address will not be published.