I have an display/sorting issue when displaying size buckets/bins using a bar chart.
The bucket labels which I’m using are strings - <500, 1k_2k, 2k_3k etc. etc., so when I plot these on the chart with the respective values in each bucket, they wont necessarily display in order of the above.
When I display this information in a table, I have created a calculated field which allocates alphabetical letters based on the bucket, so I can order them A –> Z (e.g. the above would be A, B, C etc. etc.). I add this to the table, sort accordingly and just hide the column.
Is there any way to do this when using the bar chart?
I don’t want to change the bucket/bins to a.<500, b.1k_2k, c.2k_3k etc. etc.
Did my answer help you in resolving your request? If yes, I would request you to mark the post as “Solution”. This will help the community to find guidance and answers to similar question. Thank you!
Thanks for the resposne - I knew there would be a way to do this.
Unfortunately, this has not worked for me. Below is some test data I have used, where I have created calculated filed “bucket"_sort” which assigns values a-e to the relevant bucket type:
I have applied the off-visual sorting, but what appears to have happened is that is it sorting the bucket field based on the string value - i.e. 10 –> 1 –> 20 –> 5 etc.
This is not the intended hehaviour. Also, the sorting now does not change when I select ascending or descending - it just stays as the above.
my bad. I thought it is possible to sort strings (a b c) in an alphabetical order. Numbers are better. Please change your calculation from a b c to 1 2 3.
Thanks for this, but unfortunately this does not work.
Changing the “bucket_sort” to numbers (integers) wont work as i need to return the same data type when doing the calulcation, and as the “buckets” are strings, I need to retrun them as such.
Even changing 1, 2,3 etc. to “1”, “2”, “3” as strings, the sorting applied on screen is the same as when I was using alphabetical letters - i.e. the sort is occurs on the string values from the “buckets” field and the bar chart is ordered 10 –> 1 –> 20 –> 5 etc.
Do you think this could a limitation of the graphic itself or is there something else going on here?
As mentioned, I’m using a simple bar chart and then using the sort by “off-field” visual using the calculated field of bucket_sort pasted earlier in the thread.
I have tried this on another categorical field in a bar chart (with a calculated field to sort that categorical field) - but I’m getting the same result, in that it is sorting the string values based on alphabetical order.