Forum Discussion
Bar Chart Sort w/Groups
Hello everyone -
Tried searching and attempted a few resolutions but was unable to solve this. Would appreciate your help.
I have a data set as follows:
Column title: Tenure
Data Inside: Employee tenure in years, by decimal, for an accurate visual
I'm trying to create a visual which will showcase #of EEs by Tenure in buckets. I tried two things to resolve this sorting issue
1. Creating a conditional column and categorizing tenure by buckets, then visualize :/ sorting was still off
2. Created groups based on the column and list the variables then categorize, still same issue when sorting
Here's the resulted visual . . any advice would be helpful! As you can see the tenure years are not in order. 5.1-10 should not be last.
Hello Anonymous
What you need is a numeric column in your data that tells PowerBI how to sort your Tenure column. In my example I added a column to the table based on the Tenure Months.
TenureSort = SWITCH ( TRUE (), Employees[Tenure Months] < 13, 1, Employees[Tenure Months] < 61, 2, Employees[Tenure Months] < 121, 3, Employees[Tenure Months] < 181, 4, 5 )Use the same logic for this column that you used for the Tenure column, just return the number instead.
Then, in the table, select the Tenure column and set the "Sort by Column" to be TenureSort.
That sorting gets applied to the Tenure column in the visual.
4 Replies
- AnonymousNot applicable
Hi,
When you MouseOver the Visual. You would see Three Dots on the Right Side Top Corner of the Visual. Clicking on it would provide a list of Selection in which you would need to Select Sort Ascending and in the Last Item called Values Expand it and Select the X-Axis Category.
Accept as a Solution if this has solved your issue :)
- AnonymousNot applicable
Hi I tried that before ;) with both of my approaches as described above. Unfortunately, it's still the same. :(
- jdbuchanan71Super User
Hello Anonymous
What you need is a numeric column in your data that tells PowerBI how to sort your Tenure column. In my example I added a column to the table based on the Tenure Months.
TenureSort = SWITCH ( TRUE (), Employees[Tenure Months] < 13, 1, Employees[Tenure Months] < 61, 2, Employees[Tenure Months] < 121, 3, Employees[Tenure Months] < 181, 4, 5 )Use the same logic for this column that you used for the Tenure column, just return the number instead.
Then, in the table, select the Tenure column and set the "Sort by Column" to be TenureSort.
That sorting gets applied to the Tenure column in the visual.
- AnonymousNot applicable
Genius! thank you, that worked. :)