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:
- Create a collection which contains all months as text
- Create another collection, which appends month-number to each month
- 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:
Comments
Post a Comment