cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
atagios
Frequent Visitor

DropDown for week selection for the year

Hi,

I am trying to create a dropdown that will display the weeks (starting on Monday) of the year, but I cannot figure out the math calculation.

On start of the app I am using the Sequence function to create a global var for the dropdown items table as following:

 

//Collection of 52 Weeks 

    Set(weeksList,

        ForAll(Sequence(52,

                Day(DateAdd(Today(),-1 * (Weekday(Today(),Monday) - 1),Days)

                ) - 182,  //This is 26weeks =(182days/7days)

                7

            ),

            Date(Year(Today()),Month(Today()),

                Value

            )

        )

    );

And for the dropdown the items property is:

AddColumns(weeksList,"WeekEnd",DateAdd(Value,6,Days),"Week Display",Value&" to "&DateAdd(Value,6,Days))

For some specific dates eg:If the date is Jun 01 2021 the formula is not working correct

weeksDrpDown2021.png

Can anyone help, I believe the problem is in my calculation OnStart where the sequence of 52 weeks (26past the current week Monday and 26 next weeks), that -182 it is wrong?

1 ACCEPTED SOLUTION

Accepted Solutions
v-jefferni
Community Support
Community Support

Hi @atagios ,

 

Please try below formula OnStart:

ClearCollect(weeksList,
        ForAll(Sequence(52,-26,1) As DD,
            DateAdd(DateAdd(Today(),-Weekday(Today(),Monday)+1),7 * DD.Value ,Days)
        )
);

 

This formula simply get the date of current week's Monday then calculate the date of all the 52 weeks' Mondays.

 

Hope this helps.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

2 REPLIES 2
v-jefferni
Community Support
Community Support

Hi @atagios ,

 

Please try below formula OnStart:

ClearCollect(weeksList,
        ForAll(Sequence(52,-26,1) As DD,
            DateAdd(DateAdd(Today(),-Weekday(Today(),Monday)+1),7 * DD.Value ,Days)
        )
);

 

This formula simply get the date of current week's Monday then calculate the date of all the 52 weeks' Mondays.

 

Hope this helps.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

Hi @v-jefferni 

Thank you, it seems that your suggestion is working!!!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,155)