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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Applicable88
Impactful Individual
Impactful Individual

Turn the year from a datetable into ISO-Year

Hello,

I have a standard datetable like US-Standards. In europe ISO - standard is common. The first week of the year needs to have at least 4 days in January. So according to ISO the first week in 2021 starts on Jan 4th. So the first three days in Jan are 2020/53. I use the weeknum() function with return type 21 to generate the right weeknumbers. I use the function  CombinedYearWeek= Calendar[Year]&"/"& format(WEEKNUM(Calendar[Date],21),"00"to generate a column á la YYYY/WW, which results having the years of this year, but the calendarweek 53 belongs to 2020. How can I generate a column like  "ModifiedYear"in my sample table, that all dates get the right year according to ISO, so I can combine it with the weeknum()-function correctly. 

DateCalendar YearWeekWeeknum() CombinedYearWeekModifiedYear
2021-01-0120210153 2021/532020
2021-01-0220210153 2021/532020
2021-01-0320210153 2021/532020
2021-01-0420210201 2021/012021

 

What I get instead looks like this, a slicer sort descending including todays week:

Applicable88_0-1632481757940.png

 

This would imply that week 53 belongs to this year, which is wrong, it belongs to last year hence 2020/53 should be right. Since I have no data after week38, which is the week today it also is misleading.

Hope someone has a solution.

Best. 

 

1 ACCEPTED SOLUTION

I found a solution:

First we need the correct calendar weeks according to ISO. Then the year can be calculated from that "correct" week column, with another calculated column:

ISOYear = YEAR('Date'[Date] + 26 - 'Date'[ISOWeekNumber])

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Applicable88 , Try to take year from week start date

 

Monday

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

 

Sunday

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

 

week Year = year[Week Start Date])

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Oh @amitchandak, I was wrong. That formula is not going to work, because its not adapting that every year changes. For this year it might work, but for example when January 2019 really had 4 days in the first week, the remaining two days of December 2018 , means the 30th and 31st belongs to the 2019 hence are calendarweek 2019/01 according to ISO. Any other methods?

I found a solution:

First we need the correct calendar weeks according to ISO. Then the year can be calculated from that "correct" week column, with another calculated column:

ISOYear = YEAR('Date'[Date] + 26 - 'Date'[ISOWeekNumber])

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.