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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Week grouping not considering last week of the year

Hi all,

 

I have the calculated column below to group my week as per the week end date. This was a suggestion from a community member and it worked very well except for the last week of the year which has december and then goes into January. The formula then breaks that into 2 different weeks. Please see below. Does anyone know a way to group that last week together as well?week.JPG

Column 2 = 
VAR __yearWeek = FORMAT( 'Calendar'[Date], "YYYYWW" )
RETURN
CALCULATE(
    MAX( 'Calendar'[Date] ),
    ALL( 'Calendar' ),
    FORMAT( 'Calendar'[Date], "YYYYWW" ) = __yearWeek
)

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

Please try to create the calculated column getNextSat :

getNextSaturday.JPG

getNextSat = 'Calendar'[Date]
    + SWITCH (
        WEEKDAY ( 'Calendar'[Date], 1 ),
        1, 6,
        2, 5,
        3, 4,
        4, 3,
        5, 2,
        6, 1,
        7, 0
    )
You can get the sample pbix file from this link.
 
Best Regards
Rena

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

It is better that you create a week start or weekend date and then use this

 

Week End date = DATEADD('Compare Date'[Compare Date],7-1*WEEKDAY('Compare Date'[Compare Date]),DAY)
Week Start date = DATEADD('Compare Date'[Compare Date],-1*WEEKDAY('Compare Date'[Compare Date])+1,DAY)

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Ashish_Mathur
Super User
Super User

Hi,

What exact result are you expecting?


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

@Ashish_Mathur Expected result is to group 7 days from Sunday to Saturday and show the last day of the week, for example for the week from 01/05/2020 to 01/11/2020 I want to see 01/11/2020  , for the week from 01/12/2020 to 01/18/2020 I want to see 01/18/2020 and so on.

 

Thanks!

Anonymous
Not applicable

Hi @Anonymous ,

Please try to create the calculated column getNextSat :

getNextSaturday.JPG

getNextSat = 'Calendar'[Date]
    + SWITCH (
        WEEKDAY ( 'Calendar'[Date], 1 ),
        1, 6,
        2, 5,
        3, 4,
        4, 3,
        5, 2,
        6, 1,
        7, 0
    )
You can get the sample pbix file from this link.
 
Best Regards
Rena

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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