cancel
Showing results for
Did you mean:
Frequent Visitor

## DAX Weeknum

Hi

Here in year 2021 I notice several of my reports where I use a "Year Week" DAX function, the result gives the wrong week number.

Data from 4th of  january to 10th should show up as in week 1, but instead it shows up in week 2. Data from 11th of january to 17th of january shows up as week 3 but should be week 2.

I'm using this coloumn formula:

Year Week = YEAR([Date]) & "-" & if(WEEKNUM([Date],2)<10,CONCATENATE(0,weeknum([Date],2)),weeknum([Date],2))

And I have tried to subtract 1 from the weeknum, if the year is 2021, but that doesn't change the result:

Year Week = YEAR([Date]) & "-" & if(YEAR([Date]) = 2021,if(WEEKNUM([Date],2)<10,CONCATENATE(0,weeknum([Date],2)-1),weeknum([Date],2)-1),if(WEEKNUM([Date],2)<10,CONCATENATE(0,weeknum([Date],2)),weeknum([Date]+1,2)))

Could any one help me on this?
1 ACCEPTED SOLUTION
Super User I

Regards,

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain
6 REPLIES 6
Super User I

In additon to get the first three days of 2021 in your Year Week calculated column like 2020-53 and not 2021-53 use the following code for the ISO Year:

Regards,

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain
Responsive Resident

@allannissen79 To obtain ISO Week Number you need to use 21 as the second argument as mentioned by @Payeras_BI

Super User I

Regards,

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain
Frequent Visitor

Edit: It did actually work! 😉

Thanks, it doesn't work for me.

Super User IV

@allannissen79 , I think this same as issue reported here

https://community.powerbi.com/t5/Issues/DAX-WEEKNUM-gives-incorrect-values-since-jan-1st-2021/idi-p/...

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

min week start of year = minx(filter('Date',year([Week Start date])=earlier(year(Week Start date]))),[Week Start date])

week No = quotient(datediff([min week start of year],[date],day),7)+1

Proud to be a Super User!

Frequent Visitor

Thanks, I will see if I can implement this in my report

Announcements

#### The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

#### Experience what’s next for Power BI

See the latest Power BI innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors