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.
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 very much for taking the time to do this. I’m familiar with the QS Arena, hence why I didnt not use it to upload - it also seems I dont have the right permissions to view the analysis (when clicking on the square box’s on the left.
I have changed the values in my calculated field to return 1, 2, 3 etc. and this now works for me, using the agg method as “Min”.
This has confused me a little, as I always thought that i the ifelse statement, it had to return the same data type as what is being passed to it i.e. if you pass a string (eg. “<1mn”), you have to return a string also. Seems my thinking was wrong here and appears to the cause of my issues.