Forum Discussion
DAX Date Table : Week Range - Sorting issue
- 3 years ago
Hi bmk ,
This error is because the column which used to sort the other column need to be the unique, the error is here (In my PBIX file, it can be seen in the ERRORHERE Table):
So we can do a little change to the column Weeknum,
New a column:
Index = IF ( 'Date Table'[Date] >= DATE ( 2021, 12, 27 ) && 'Date Table'[Date] <= DATE ( 2022, 1, 2 ), 152, ( YEAR ( 'Date Table'[Date] ) - 2020 ) * 100 + 'Date Table'[WeekNum] )You can sort by the Index column.
The result is:
Here is my PBIX file.
Hope this helps you.
Best Regards,
Community Support Team _Yinliw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi bmk ,
This error is because the column which used to sort the other column need to be the unique, the error is here (In my PBIX file, it can be seen in the ERRORHERE Table):
So we can do a little change to the column Weeknum,
New a column:
Index =
IF (
'Date Table'[Date] >= DATE ( 2021, 12, 27 )
&& 'Date Table'[Date] <= DATE ( 2022, 1, 2 ),
152,
( YEAR ( 'Date Table'[Date] ) - 2020 ) * 100 + 'Date Table'[WeekNum]
)
You can sort by the Index column.
The result is:
Here is my PBIX file.
Hope this helps you.
Best Regards,
Community Support Team _Yinliw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you. Could you please explain the logic of the Index measure here? I did not follow the IF condition completely.
- v-yinliw-msft3 years agoCommunity Support
Hi bmk ,
I post a formula here:
This is to calculate a unique column to avoid the same value, but in the week 12/27/2021 - 1/2/2022, it has a same value, so, I create a value 152 to prescribe a rule. Because I use the Year function, and this week have two years.
That is the logic of the formula. Just for sorting.
In my file, you can see two other tables to explain this.
Best Regards,
Community Support Team _Yinliw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.