Forum Discussion
Sort Category
Hi Power BI Community,
I have what seems like a trivial request - sort category.
Session is my category. In theory, Session is sorted in ascending order. However, sessions 10, 11, Aysnch are not following the rule.
I've created a conditional column to sort.
= Table.AddColumn(#"Changed Type", "Session Order", each if [Session] = 1 then 1 else if [Session] = 2 then 2 else if [Session] = 3 then 3 else if [Session] = 4 then 4 else if [Session] = 5 then 5 else if [Session] = 6 then 6 else if [Session] = 7 then 7 else if [Session] = 8 then 8 else if [Session] = 9 then 9 else if [Session] = 10 then 10 else if [Session] = 11 then 11 else if [Session] = 12 then 12 else 13)
I've sorted Session by Session Order but it is not working as intended.
Could someone provide a friendly nudge?
HI Anonymous ,
Pls test the below:
= Table.AddColumn(#"Changed Type", "ession Order", each if [Session] = "1" then 1 else if [Session] = "2" then 2 else if [Session] = "3" then 3 else if [Session] = "4" then 4 else if [Session] = "5" then 5 else if [Session] = "6" then 6 else if [Session] = "7" then 7 else if [Session] = "8" then 8 else if [Session] = "9" then 9 else if [Session] = "10" then 10 else if [Session] = "11" then 11 else if [Session] = "12" then 12 else 13)Output:
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.And if your question still not solved ,pls share your pbix file.
Best Regards,
Lucien
4 Replies
- HotChilliCommunity Champion
It's not in the provided picture - has the Session Order column been created successfully?
- AnonymousNot applicable
Hi HotChilli,
Thank you for your reply. I believe the column has been created successfully. Here is a screenshot.
Please let me know if you need anything else.
- coskuersanliResolver III
Hi Anonymous ,
I suspect that Data Type of Session Order remained as Text, can you change it to whole number and try again, please? 🙂
- v-luwang-msftCommunity Support
HI Anonymous ,
Pls test the below:
= Table.AddColumn(#"Changed Type", "ession Order", each if [Session] = "1" then 1 else if [Session] = "2" then 2 else if [Session] = "3" then 3 else if [Session] = "4" then 4 else if [Session] = "5" then 5 else if [Session] = "6" then 6 else if [Session] = "7" then 7 else if [Session] = "8" then 8 else if [Session] = "9" then 9 else if [Session] = "10" then 10 else if [Session] = "11" then 11 else if [Session] = "12" then 12 else 13)Output:
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.And if your question still not solved ,pls share your pbix file.
Best Regards,
Lucien