Show A DropDown In PowerApps Containing Only Remaining Months In The Year

Within your Power Apps, you want to have a DropDown control which will show only the remaining months of the year.

For example, if you are opening the Power App in September DropDown control will show you months from September to December only.

We can achieve this in three steps as below:

  1. Create a collection which contains all months as text
  2. Create another collection, which appends month-number to each month
  3. Add a DropDown control and Filter collection from step 2 to show only months where month-number is greater than or equal to current month number
1 - Create a collection of all months
This can be done by adding formula below at App OnStart:

Collect(
    colMonths,
    Calendar.MonthsLong()
);

This will give a collection of 12 rows, one for each month: January, February, …, December

2 - Append Month-Number to this collection
This can be done by adding formula below just after the step 1

ForAll(
    colMonths,
    Collect(
        colNumberedMonths,
        Last(
            FirstN(
                AddColumns(
                    colMonths,
                    "MonthNumber",
                    CountRows(colNumberedMonths) + 1
                ),
                CountRows(colNumberedMonths) + 1
            )
        )
    )
)

The output from this step would look like:


3 - Item property of DropDown control
At this stage, we need to include months where month-number is greater than or equal to the current month. This can be done by updating Items property of the DropDown control to:

Filter(
    colNumberedMonths,
    MonthNumber >= Month(Today())
)






Comments

Popular posts from this blog

Generate QR code within Power Automate

Restrict Attachment control in PowerApps to accept Excel files only

Get start and last date of month using Power Apps