cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
allannissen79
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
Payeras_BI
Super User I
Super User I

Hi @allannissen79 ,

 

Payeras_BI_1-1611229124522.png

 

 

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

View solution in original post

6 REPLIES 6
Payeras_BI
Super User I
Super User I

Hi @allannissen79 ,

 

I am glad it helped.

 

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:

 

Payeras_BI_1-1611237087054.png

 

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
Geradav
Responsive Resident
Responsive Resident

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

Geradav_1-1611230562451.png

 

Payeras_BI
Super User I
Super User I

Hi @allannissen79 ,

 

Payeras_BI_1-1611229124522.png

 

 

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

View solution in original post

Edit: It did actually work! 😉

 

Thanks, it doesn't work for me.

amitchandak
Super User IV
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/...


In calendar add these columns

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

 

 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

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

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

April Update

Check it Out!

Click here to read more about the April 2021 Updates!

secondImage

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.

secondImage

Experience what’s next for Power BI

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