Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
shawndempsey7
Frequent Visitor

Return all week numbers in a range

I have a large number of start and stop dates that align with employee identification numbers, and I want a count of all of the weeks that their ranges cover. Can I do this in Power BI? Thank you!

 

Example

Employee #256

start date=1/1/25

end date=1/21/25

 

Employee #257

start date=1/1/25

end date=1/7/25

 

Results

2025W1=2  2025W2=2  2025W3=1  2025W4=1

2 ACCEPTED SOLUTIONS
danextian
Super User
Super User

Hi @shawndempsey7 

You've provided your expected result but the solution depends on the actual data. We don't know what your tables look like. Are the weeks broken down into days or just a week start and end dates? Assuming that's the structure of your weeks table, please see the attached sample pbix

danextian_0-1760764663599.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

ryan_mayu
Super User
Super User

@shawndempsey7 

pls see if this is what you want

11.png





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

17 REPLIES 17
V-yubandi-msft
Community Support
Community Support

Hi @shawndempsey7 ,
As we haven’t heard back from you, we wanted to check if your issue has been resolved. If you still need any additional details, please let us know.

Shubham_rai955
Power Participant
Power Participant

Yes, Power BI can return all week numbers covered by employee date ranges using DAX and a supporting date table. The approach is to generate all dates between each employee's start and end dates, link them to a date table with a "YearWeek" column, and count week appearances.

Step-by-Step Solution

  • Create a Date Table: Add a table with all dates for your analysis period. Include a column for YearWeek (e.g., 2025W1) using DAX with WEEKNUM:

     
    YearWeek = FORMAT([Date], "YYYY") & "W" & WEEKNUM([Date], 1)
  • Generate Employee Active Dates: Use DAX or Power Query to create rows for every date in each employee's range, linking EmployeeID, Date, StartDate, EndDate.​

  • Relate Employee-Date to Date Table: Join the generated date rows to the date table on the date field, so each active date inherits a YearWeek value.​

  • Count by Week: Summarize (COUNTROWS or aggregation) by YearWeek to get counts per week. The result shows exactly how many employees are active during each week:

     
    EmployeeCountByWeek = SUMMARIZE( EmployeeActiveDates, [YearWeek], "Count", COUNTROWS(EmployeeActiveDates) )

Example Output

YearWeek EmployeeCount
2025W12 
2025W22 
2025W31 
2025W41 
 
 

With this method, you can analyze and visualize employee counts by week for any date ranges using only DAX and relationships.

theov
Advocate III
Advocate III

I would create a calendar table and do all there: https://youtu.be/Oq5WOmo94_Q?si=IDHOPH1crJGfGFoZ

ryan_mayu
Super User
Super User

@shawndempsey7 

pls see if this is what you want

11.png





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks for the continued help...this certainly gets me closer. What I am truly stuck on is that I have a start and end date. I can convert those two dates into an associated week number, but I'm struggling to capture any weeks in between, i.e. start =January 6,2025 end= January 24, 2025. This will return 2025W1=1 and 2025W3=1, but I am losing that 2025W2 should also equal 1. Does this make sense?

Hi @shawndempsey7 ,

Thanks for the clarification. The reason you’re missing some weeks is because your setup only captures the start and end weeks. To get all the weeks in between, you’ll need to generate every week number that falls within each employee’s date range.

You can do this by building a calculated table or writing a DAX formula that expands all dates (or weeks) between the start and end dates, then groups them by week.

 

Hope this helps...

Regards,
Yugandhar.

Yes, this is what I'm hoping to acheive. Thank you!

Hi @shawndempsey7 ,

Thank you for your response and for staying engaged with the community. If possible, I kindly ask that you mark @ryan_mayu reply as the accepted solution this will make it easier for other members to find and benefit from the discussion.

 

Appreciate your valuable input, @ryan_mayu .


Best regards,
Yugandhar.

danextian
Super User
Super User

Hi @shawndempsey7 

You've provided your expected result but the solution depends on the actual data. We don't know what your tables look like. Are the weeks broken down into days or just a week start and end dates? Assuming that's the structure of your weeks table, please see the attached sample pbix

danextian_0-1760764663599.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Ashish_Mathur
Super User
Super User

Hi,

Share the download link of the PBI file.  In that file, ensure that there is a Calendar table with a week column.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thank you,

 

Unfortunately, I'm getting a "The date column must have unique values." message when I attempt to created a date table. Please see the sample data link below:

https://mydocs.toyota.com/:u:/r/personal/shawn_dempsey_toyota_com1/Documents/Sample%20to%20Share.pbi...

That takes me to a sign-in page.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Sorry...I'm new to the solution and can't figure out how to share outside of my organization. However, the data is very simple:

TM#LWD TotalRWD TotalAbsence Day Counts Lost Restricted DateLWD End DateRWD End Date
3680206/10/20246/10/20246/30/2024
9072027/1/20247/1/20247/3/2024
4280123/20/20253/20/20254/1/2025
12860304/1/20254/1/20255/1/2025
87770315/1/20255/1/20256/1/2025
4720116/1/20256/1/20256/12/2025
11100197/1/20257/1/20257/20/2025
231027/30/20257/30/20258/1/2025
54900318/1/20258/1/20259/1/2025
79290309/1/20259/1/202510/1/2025
18801610/1/202510/1/202510/17/2025
51590164/15/20244/15/20245/1/2024
86460315/1/20245/1/20246/1/2024
9271036/1/20246/1/20246/4/2024
644013/31/20253/31/20254/1/2025
24580304/1/20254/1/20255/1/2025
8590315/1/20255/1/20256/1/2025
12980306/1/20256/1/20257/1/2025
92553107/1/20258/1/20257/1/2025
63371908/1/20258/20/20258/1/2025
9938059/26/20249/26/202410/1/2024
380601610/1/202410/1/202410/17/2024
2466034/28/20254/28/20255/1/2025
50990315/1/20255/1/20256/1/2025
60940306/1/20256/1/20257/1/2025
46370107/1/20257/1/20257/11/2025
9001199/1/20259/2/20259/20/2025

As requested, please also share a Calendar table with a week number column (since i do not know what the start and end of week is for you).  Also, for a few rows of the sample data, show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Sorry...hope this clarifies:

TM#LWD TotalRWD TotalAbsence Day Counts Lost Restricted DateLWD End DateRWD End DateAbsense Week StartLWD Week EndRWD Week EndYear-WeekDesired LWD ResultDesired RWD Result
39203101/1/20242/1/20241/1/20241512024-W123
4131901/1/20241/10/20241/1/20241212024-W223
70770311/1/20241/1/20242/1/20241152024-W313
3390311/1/20241/1/20242/1/20241152024-W4 13
57770311/1/20241/1/20242/1/20241152024-W513
Shahid12523
Community Champion
Community Champion

Create a Date table with Date, WeekNum, and YearWeek (e.g., "2025W01").
Expand each employee’s date range using CALENDAR(StartDate, EndDate).
Join with the Date table to get YearWeek for each date.
Summarize by YearWeek to count how many employees are active per week.

Shahed Shaikh

Thank you,

 

Unfortunately, I'm getting a "The date column must have unique values." message when I attempt to created a date table.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors