Forum Discussion
Date table sorting error
Hi everyone,
The extract of my current dates table:
So i have managed to create a date table with the help of other users and everything was fine untill i tried to sort one of my tables based on the week value. i tried to sort by week both ascending descending and im not getting the correct sorting. The only waz i can get it to work is when i add the week number to my table and the issue with this approach is on the following screenshot. Power bi is putting the last weeks of 2019 after the first weeks of 2020.
I would appreciate if anyone has an idea on how to tackle this issue.
Thanks in advance
2 Replies
- Greg_DecklerCommunity Champion
- Mous007Helper IV
Hello there Greg_Deckler , thanks a lot for your prompt reply.
I have tried to following column based on your link but it seems that its not working;
Column =VAR MaxWeeks = SUMMARIZE(ALL('DatesTable'[Week number]),'DatesTable'[Week number],"MaxWeek",MAX('DatesTable'[Week number]))VAR MyYear = [Calendar Year]VAR MyStart = SUMX(FILTER(MaxWeeks,[Calendar Year]<MyYear),[MaxWeek])VAR firstYear = CALCULATE(FIRSTNONBLANK('DatesTable'[Calendar Year],1),ALL(DatesTable[Week number]))VAR myNum = IF(MyYear=firstYear,[Week number],MyStart+[Week number])RETURN myNumand my table is still returning the following;maybe i am not using your technique correctly or i have made an error in my dax.Any recommendations would be appreciated.