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
Super User
Super User

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
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (2,730)