Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

WeekNum sequence issue

Hi there,

 

I created a Date table as following:

The weekNumber dax is:

WeekNum = "Wk" & WEEKNUM('Date'[Date])
 
 

However, the weekNumber does not work well in chart sequence.

The actual sequence is:

2020 wk1, then wk 10, 11,....wk19, wk2, wk20,21...wk29, wk3, wk30....

 
 

I think it is because text "wk" is added in front.

Is there a way to make it correctly as wk1, wk2, wk3....wk10, wk11..., wk19, wk20, wk21?

Thanks for the help.

H

  • Hi Anonymous ,

     

    you need two columns, one with the week as an int, the other as the week as a string, then you will sort the week as a string by the week as int. see image below

     

     

15 Replies

  • richbenmintz's avatar
    richbenmintz
    Icon for Resident Rockstar rankResident Rockstar

    Hi Anonymous ,

    create a column called Wk as 

    WEEKNUM('Date'[Date])

    then set the 'Sort By Column' of the weekNumber field to your newly created Wk field.

     

    you will find the property in the properties pane or in the columns ribbon

     

    thanks

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi richbenmintz,

       

      I've set it. but as you can see, "wk10" is the one after "wk1", but not "wk2" after "wk1"

       

      Did I set it correctly?

      Thanks.

      H

      • richbenmintz's avatar
        richbenmintz
        Icon for Resident Rockstar rankResident Rockstar

        Hi Anonymous ,

         

        That is the correct setting, but you need to sort by the weenknum as a number, the string wk3 comes after wk29