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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

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])

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

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
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.