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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (4,600)