web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Need dynamic sequence ...
Power Apps
Answered

Need dynamic sequence - List of Weeks for current month

(0) ShareShare
ReportReport
Posted on by 327

(update) Hi all

 

is it possible to create a dynamic sequence for the number of weeks based on the current month?

which I then want to use for a drop-down/combo box control (Collection as item?)

 

currently using 

 

 

"Week " & RoundDown(
 (Day(Today()) - Day(DateValue("1/1/" & Year(Today()))) + Weekday(DateValue("1/1/" & Year(Today())) - 1)) / 7,
 0
) + 1

 

on a text label which just gives the current week number for the current month (this gives correct week)

 

  Issue:

ClearCollect(
 AvailableWeeks,
 AddColumns(
 Sequence(
 RoundUp(
 (Day(
 DateAdd(
 Date(
 Year(Today()),
 Month(Today()) + 1,
 1
 ),
 -1,
 TimeUnit.Days
 )
 ) -// Last day of the current month
 Day(
 Date(
 Year(Today()),
 Month(Today()),
 1
 )
 ) + 1 +// Day of the first day of the current month
 Weekday(
 Date(
 Year(Today()),
 Month(Today()),
 1
 ) - Day(
 Date(
 Year(Today()),
 Month(Today()),
 1
 )
 ) + 1
 )// Weekday of the first day of the current month
) / 7,
 0
 )
 ),
 "WeekNumber",
 "Week " & Value
 )
);

moerah_0-1708020393259.png

this gives 5 weeks which is wrong as February has 4 weeks 

 

any suggestion would be great 

 

thank you 😃

Categories:
I have the same question (0)
  • Verified answer
    LEGRANCHE Profile Picture
    on at

    Hi

     

    to get the number of weeks within the current month, you can use the following:

    With(
     {StartDate:Date(Year(Today()), Month(Today()),1)},
     ISOWeekNum(DateAdd(StartDate,1,TimeUnit.Months))-ISOWeekNum(StartDate)
    )

     

    Now to use it for the property items of drop-down, use the following:

    With(
     {StartDate:Date(Year(Today()), Month(Today()),1)},
     Filter([1,2,3,4,5,6],Value<1+ISOWeekNum(DateAdd(StartDate,1,TimeUnit.Months))-ISOWeekNum(StartDate))
    )

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.

  • moerah Profile Picture
    327 on at

    @LEGRANCHE Woww! Thank you so much 😀

     

    did not even have to use clear collect ,learn something new every day 

     

    this works perfect for my items

    With(
     {StartDate: Date(Year(Today()), Month(Today()), 1)},
     AddColumns(
     Filter(
     [1, 2, 3, 4, 5, 6],
     Value < 1 + ISOWeekNum(DateAdd(StartDate, 1, TimeUnit.Months)) - ISOWeekNum(StartDate)
     ),
     "WeekNumber",
     "Week " & Text(Value)
     )
    )

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 431

#2
WarrenBelz Profile Picture

WarrenBelz 360 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 280 Super User 2026 Season 1

Last 30 days Overall leaderboard