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 / [PowerApps] Automatic ...
Power Apps
Unanswered

[PowerApps] Automatic item choices for Week dropdown based on selected Month

(0) ShareShare
ReportReport
Posted on by

Hi! So i'm currently trying to establish a relationship between two dropdowns: Month and Week and Date Picker (I'm using modern controls)


CONTEXT

Here's what it needs to do. If I choose a month, lets say "May" the dropdown for Week should automatically populate based on the weeks for May (Week 19 - Week 22). Should look like this in the Week dropdown:

  • Week 19
  • Week 20
  • Week 21
  • Week 22

Ideally:

  • Week 19 (Monday - Saturday dates for the week) and so on


ISSUE
Now here is my code for the OnChange property in my month dropdown. The thing is, it's working but the items listed in the Week are random numbers instead of Week 19 - 20 when i choose the month May. Can I ask for help on what should change for this code or like initialize first. Thank you!

 

 

 

If(!IsBlank(inp1_ANMonth.Selected.MonthNumber),

With(

{

FirstDayOfMonth: Date(Year(Today()), inp1_ANMonth.Selected.MonthNumber, 1)

},

With(

{

FirstDayOfWeek: Weekday(FirstDayOfMonth, StartOfWeek.Monday)

},

ClearCollect(WeeksForSelectedMonth,

Table(

{WeekStart: FirstDayOfMonth - FirstDayOfWeek + 1, WeekNumber: "Week 1"},

{WeekStart: DateAdd(FirstDayOfMonth, 7 - FirstDayOfWeek), WeekNumber: "Week 2"},

{WeekStart: DateAdd(FirstDayOfMonth, 14 - FirstDayOfWeek), WeekNumber: "Week 3"},

{WeekStart: DateAdd(FirstDayOfMonth, 21 - FirstDayOfWeek), WeekNumber: "Week 4"},

// Add more records here if the month has more than 4 weeks

// The following is an example for a fifth week; adjust as necessary

{WeekStart: DateAdd(FirstDayOfMonth, 28 - FirstDayOfWeek), WeekNumber: "Week 5"}

// Ensure the last week doesn't exceed the month's days

)

)

)

),

Clear(WeeksForSelectedMonth) // Clear the collection if the month is blank

)

 

 

Categories:
I have the same question (0)

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard