cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
anonymia25
Helper IV
Helper IV

Filter dropdown months

Hello,
How do I filter a dropdown to only show current month and the next months?


 

1 ACCEPTED SOLUTION

Accepted Solutions

Create a numbered collection like below

happyume_0-1626947546901.png

 



Collect(col_months,Calendar.MonthsLong());
ForAll(col_months,
Collect(colNumberedMonths,
Last(FirstN(AddColumns(col_months,
"RowNumber",
CountRows(colNumberedMonths)+1
),
CountRows(colNumberedMonths)+1
)
)
)
)

 

and then in Items property, Filter(colNumberedMonths,RowNumber>=Month(Today()))

happyume_1-1626947645074.png

 



View solution in original post

11 REPLIES 11
v-qiaqi-msft
Community Support
Community Support

Hi @anonymia25

Based on the issue that you mentioned, do you want to display the current month and next month in a Dropdown?

Please set the Items property as below:

Table({Month:"CurrentMonth:"&Month(Today())},{Month:"NextMonth:"&Month(DateAdd(Today(), 1, Months))})

vqiaqimsft_0-1626937706634.png

 

Best Regards,
Qi
KvB1
Solution Sage
Solution Sage

Thought this would be simple, but ended up creating a collection that you'd have to create OnStart and add to Item propery of the dropdown

 

 

Clear(colMonths);;
ClearCollect(
    NumberCollection;
    "1";
    "2";
    "3";
    "4";
    "5";
    "6";
    "7";
    "8";
    "9";
    "10";
    "11";
    "12"
);;
ForAll(
    FirstN(
        NumberCollection;
        12 - Value(
            Text(
                Today();
                "mm"
            )
        )
    );
    Collect(
        colMonths;
        {
            Number: Value(
                Text(
                    Today();
                    "mm"
                )
            ) + ThisRecord.Value;
            Month: Text(
                DateAdd(
                    Today();
                    Value(ThisRecord.Value);
                    Months
                );
                "mmm"
            )
        }
    )
)

 

happyume
Solution Sage
Solution Sage

In your App OnStart or Screen OnVisible, create a collection as:

Collect(AllMonths,Calendar.MonthsLong())

happyume_0-1626939316743.png

 

In your DropDown control, add Items as AllMonths and Default as Text(Today(),"mmmm")

happyume_1-1626939368575.png

 

Hi @v-qiaqi-msft,

Yes, I wanted to display the current month and the next months, for example this current month is July so the dropdown will list July until December..

How do I make the formula automatically calculate the current and the next months?
Thanks!

Hi, @happyume 

Your method is simple and easy to understand but I am wondering if the previous months can be hidden from the list? Meaning only show the current and future months? Thank you so much.

Hi @anonymia25,

I think you have something misunderstanding with my solution. It is dynamically based on the Today().

Just imagine that the current date is 1/5/2021, the Dropdown will always display 1 and 2. So as the following days.

The Today() function changes dynamically based on the time flies.

Best Regards,
Qi
KvB1
Solution Sage
Solution Sage

I think they want the dropdown to display todays month, and all the other months of this year between this month and the end of the year. The only solution I found is to create 2 collections on start, needed to determine the amount of months to be added to the collection, and to assign the appropiate month name. 

Create a numbered collection like below

happyume_0-1626947546901.png

 



Collect(col_months,Calendar.MonthsLong());
ForAll(col_months,
Collect(colNumberedMonths,
Last(FirstN(AddColumns(col_months,
"RowNumber",
CountRows(colNumberedMonths)+1
),
CountRows(colNumberedMonths)+1
)
)
)
)

 

and then in Items property, Filter(colNumberedMonths,RowNumber>=Month(Today()))

happyume_1-1626947645074.png

 



@KvB1 yes that is what i meant, and i have tried your solution but turns out there is error

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (2,300)