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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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