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.

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

3 REPLIES 3
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.

Community Support Team _ Jeffer Ni

If this post helps, then please consider Accept it as the solution to help the other members find it.

Hi @v-jefferni 

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

New_Learner
Frequent Visitor

Hi @v-jefferni 

I want only current months weeks in dropdown

Set(
    weeksList,
    ForAll(
        Sequence(5,-3,1) As DD,
        DateAdd(DateAdd(Today(),-Weekday(Today(),Monday) + 1),7 * DD.Value,Days)
    )
);

 

I have added this on OnStart of the App

It 's currently giving me correct outputs as wanted
Lists of 5 weeks: Like below

8/1/2022 - 8/7/2022

8/8/2022 - 14/8/2022

8/15/2022 - 8/21/2022

8/22/2022 - 8/28/2022

8/29/2022 - 9/4/2022

 


But in the next week :   It will give list as :

8/8/2022 - 14/8/2022

8/15/2022 - 8/21/2022

8/22/2022 - 8/28/2022

8/29/2022 - 9/4/2022
9/5/2022 - 9/11/2022

How can I restrict only current months week list ?
Can you please help me with this?




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 (5,174)