Forum Discussion
Using a Categorical Variable Parameter on Axis and Sort Reverting to Default.
Thanks for the reply from parry2k , please allow me to provide another insight:
Hi, hjolley
Your approach to sorting the columns is correct, but you need to sort each column selected by your parameter. For example:
Here is my sample data:
1.I have sorted each column based on the index column:
2.Here is the final result, which I hope meets your requirements:
Please note that the columns being sorted must not contain duplicate values, as this will result in a sorting error.
Please find the attached pbix relevant to the case.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
All the categorical columns have duplicate values. I am plotting a metric against a changing categorical variable so all the values are a creation of many, many rows.
I'm not entirely sure why your PowerBI graphs don't have a default sort axis but the problem is that whatever I do it defaults back to the numeric metric like so:
Vs yours, which does not in fact have a default sort at all:
- Anonymous1 year agoNot applicable
Hi, hjolley
Thank you for your swift response.
I apologise for any confusion caused. Your sorting method differs from mine. I use the position shown in the image below:
If your sorting column contains duplicates, the corresponding index values for those rows must also be duplicated:
I recommend using my method for sorting, as it can more effectively resolve your issue.
Of course, if you have any new ideas, you are welcome to contact us.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- hjolley1 year agoRegular Visitor
I have no concerns with the sort order of the categorical variable when I can get the graph to sort by the categorical variable. The problem is that my graphs for some reason will not stay sorted by the character variable.
I don't know why your graphs don't have a default sort axis (maybe because the data is already summarized?) but I believe that is the core of the problem, not what the categorical variables are sorted by (currently, they are sorted by themselves).
I don't care if the data remains in data source order; I care that two graphs sort the same way, whatever that is.
- Anonymous1 year agoNot applicable
Hi, hjolley
Thank you for your swift response.
Your observation is very detailed. However, I need to clarify further:
In my visualisation, the reason for not using the default sorting and instead sorting by the index column is that I modified each column’s “sort by column” setting and sorted by the index column.
This is why I recommend using the “sort by column” method to sort the x-axis of your visualisation.
I hope my explanation is clear enough. If you have any further questions, please feel free to contact us.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.