cancel
Showing results for 
Search instead for 
Did you mean: 
Get Started Discussions
Start your journey with Databricks by joining discussions on getting started guides, tutorials, and introductory topics. Connect with beginners and experts alike to kickstart your Databricks experience.
cancel
Showing results for 
Search instead for 
Did you mean: 

Broken x-axis sort order in combo chart

treesloth
New Contributor III

Hello.  I am using the Combo Chart to create a Pareto visual.  I have an SQL query with built-in ordering, with output like:

 categorysort_ordercategory_countcumulative_pct
1SQL15229.9
2Python23922.4
3R32112.1
4.Net4169.2
5Bash584.6
6All Others63821.8

That's not the whole dataset, of course.  It's more complicated, but that's idea.  I'd be happy to post the script if it would help.  Anyway, I created (or, really, Genie created) a combo chart based on the data.  It worked, and the chart displayed in the same order on the x-axis as the sort_order in the data.  I liked it, but realized I needed to modify it a little.  That was successful, but the sorting is now ruined.  I didn't intentionally apply a sort, now it goes by 'category' alphabetical order.

So, at some point, it's as though the visualization editor applied no sort at all... it just went by the SQL order.  Now it does apply a sort order.  FWIW, the editor does currently have an alphabetical ordering applied:

treesloth_0-1789152950131.png

So, it's like I need to somehow tell it to use no ordering at all.  Maybe.  Or maybe it doesn't work like that at all.  But how do I get it to use sort_order again like it did before?  Or is something else going on here that I don't understand?

1 ACCEPTED SOLUTION

Accepted Solutions

Ashwin_DSA
Databricks Employee
Databricks Employee

Hi @treesloth,

 
The combo chart visualisation does not support "By field" sorting on the x-axis. If you open the x-axis kebab menu, you'll see that the "By field" option is greyed out with a "Not available for this visualisation" tooltip. This means you can't point the x-axis sort at your sort_order column the way you could with a regular bar chart. The only sort options available for combo charts are Alphabetical and Custom.
 
I reproduced this in my own workspace using a simplified version of your dataset to confirm the behaviour. Here's what I found.
 
orderbyField.png
 
When Genie first created the chart, it likely set up the visualisation without an explicit sort, so the chart reflected your SQL row order. The moment you edited the widget in the visual editor, the editor took ownership of the sort configuration and applied its default, which is alphabetical. That's why it broke after your edit, even though you didn't intentionally change the sort.
 
Here are a couple of workarounds you can try. 
 
Option 1: Custom sort (quick fix): Open the x-axis kebab menu, choose Custom under Sort, and drag the category values into your Pareto order: SQL, Python, R, .Net, Bash, All Others. This works perfectly, but is manual. If your underlying data changes and new categories appear, you'll need to re-drag them into position.
Ashwin_DSA_0-1789298164091.png
 
Option 2: SQL prefix trick (automatic fix)
If your data changes frequently and you don't want to manually reorder every time, you can prepend the sort order to the category name directly in your SQL. Something like:
SELECT 
  CONCAT(LPAD(CAST(sort_order AS STRING), 2, '0'), '. ', category) AS category, 
  sort_order, 
  category_count, 
  cumulative_pct
FROM (
  -- your original query here
)
ORDER BY sort_order
 
This turns your categories into 01. SQL, 02. Python, 03. R, and so on. Since the editor's alphabetical sort now sorts 01... before 02..., the Pareto order is preserved automatically. The tradeoff is that your x-axis labels will have the numeric prefix, which isn't as clean, but it's fully hands-off when data changes.
Ashwin_DSA_1-1789298335209.png
If your categories are fairly stable, go with Custom sort. It gives you clean labels and exact control. If your query is dynamic and categories shift over time, the SQL prefix approach saves you from having to re-drag things every time you refresh.
 
Hope that helps! Let us know if you run into anything else.

If this answer resolves your question, could you mark it as “Accept as Solution”? That helps other users quickly find the correct fix.

Regards,
Ashwin | Delivery Solution Architect @ Databricks
Helping you build and scale the Data Intelligence Platform.
***Opinions are my own***

View solution in original post

2 REPLIES 2

Ashwin_DSA
Databricks Employee
Databricks Employee

Hi @treesloth,

 
The combo chart visualisation does not support "By field" sorting on the x-axis. If you open the x-axis kebab menu, you'll see that the "By field" option is greyed out with a "Not available for this visualisation" tooltip. This means you can't point the x-axis sort at your sort_order column the way you could with a regular bar chart. The only sort options available for combo charts are Alphabetical and Custom.
 
I reproduced this in my own workspace using a simplified version of your dataset to confirm the behaviour. Here's what I found.
 
orderbyField.png
 
When Genie first created the chart, it likely set up the visualisation without an explicit sort, so the chart reflected your SQL row order. The moment you edited the widget in the visual editor, the editor took ownership of the sort configuration and applied its default, which is alphabetical. That's why it broke after your edit, even though you didn't intentionally change the sort.
 
Here are a couple of workarounds you can try. 
 
Option 1: Custom sort (quick fix): Open the x-axis kebab menu, choose Custom under Sort, and drag the category values into your Pareto order: SQL, Python, R, .Net, Bash, All Others. This works perfectly, but is manual. If your underlying data changes and new categories appear, you'll need to re-drag them into position.
Ashwin_DSA_0-1789298164091.png
 
Option 2: SQL prefix trick (automatic fix)
If your data changes frequently and you don't want to manually reorder every time, you can prepend the sort order to the category name directly in your SQL. Something like:
SELECT 
  CONCAT(LPAD(CAST(sort_order AS STRING), 2, '0'), '. ', category) AS category, 
  sort_order, 
  category_count, 
  cumulative_pct
FROM (
  -- your original query here
)
ORDER BY sort_order
 
This turns your categories into 01. SQL, 02. Python, 03. R, and so on. Since the editor's alphabetical sort now sorts 01... before 02..., the Pareto order is preserved automatically. The tradeoff is that your x-axis labels will have the numeric prefix, which isn't as clean, but it's fully hands-off when data changes.
Ashwin_DSA_1-1789298335209.png
If your categories are fairly stable, go with Custom sort. It gives you clean labels and exact control. If your query is dynamic and categories shift over time, the SQL prefix approach saves you from having to re-drag things every time you refresh.
 
Hope that helps! Let us know if you run into anything else.

If this answer resolves your question, could you mark it as “Accept as Solution”? That helps other users quickly find the correct fix.

Regards,
Ashwin | Delivery Solution Architect @ Databricks
Helping you build and scale the Data Intelligence Platform.
***Opinions are my own***

treesloth
New Contributor III

Thank you.  I appreciate the detailed response.  I'd already done the second option as what I hoped would be a temporary workaround.  Sadly, the categories are far from stable, and orders can switch (although that's not quite as common).  But, at least now I know I'm not crazy (or, at least, that this is not what proves it).  Thank you.