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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Expression for year and week

Hi, I have an issue with my Year Week expression whenever there is a new year. When looking at weekly aggregated data I would like entire week 52 to be counted into year 2021, although the ending of week 52 is in the next year. 

This is my current code:

Calendar = ADDCOLUMNS (
CALENDAR (DATE(2016,1,1),TODAY()),
"Week", CONCATENATE(CONCATENATE(FORMAT([Date], "yyyy"), " W"),Format(WEEKNUM([Date], 21), "00"))
)

And this is my regions calendar layout (In DAX format: 21)

calendar.png

 
DateCurrent outcome (Year Week)Desired outcome (Year Week)
30 dec 20212021 W522021 W52
31 dec 20212021 W522021 W52
1 jan 20222022 W522021 W52
2 jan 20222022 W522021 W52
3 jan 20222022 W012022 W01
 
 

 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , Take the year from week's start date

 

Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1

 

Year Week =  year([Week Start Date]) * 100 + [Your Week Number column]

View solution in original post

Vijay_A_Verma
Super User
Super User

Use below formula for your calendar

Calendar = ADDCOLUMNS (
CALENDAR (DATE(2016,1,1),TODAY()),
"Week", CONCATENATE(CONCATENATE(FORMAT([Date]+1-WEEKDAY([Date]-1), "yyyy"), " W"),Format(WEEKNUM([Date], 21), "00"))
)

View solution in original post

2 REPLIES 2
Vijay_A_Verma
Super User
Super User

Use below formula for your calendar

Calendar = ADDCOLUMNS (
CALENDAR (DATE(2016,1,1),TODAY()),
"Week", CONCATENATE(CONCATENATE(FORMAT([Date]+1-WEEKDAY([Date]-1), "yyyy"), " W"),Format(WEEKNUM([Date], 21), "00"))
)
amitchandak
Super User
Super User

@Anonymous , Take the year from week's start date

 

Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1

 

Year Week =  year([Week Start Date]) * 100 + [Your Week Number column]

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.