Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Sort two columns on the same one column

I would like to create a bar chart with these columns: Category, Subcategory, Quantity

 

The x axis will be both Category and Subcategory.

 

The y axis will be Quantity.

 

I want to sort Category and Subcategory by descending order of Quantity. What this means is Category bars will be from tallest bar to shortest. Then, after drilling down, the Subcategories belonging to each Category will also be sorted from tallest bar to shortest bar.

 

I've tried:

 

1. Transform Data > Group by Category with Sum of Quantity as aggregation > Sort > Add Index > Sort Category column with Index 

 

- this doesn't work because I have other columns in the same table which I'm using as Slicer.

 

2. The same thing as #1 but on Subcategory 

 

- doesn't work as well. Same reason as #1

 

3. Add Category, Subcategory and Quantity in a Table visual > Shift click on Category and Quantity > Change Table visual to Bar chart 

 

- this doesn't work because although the Subcategories will sort in descending order of Quantity within their respective Category, the Category is not sorted by Quantity but by alphabetical order.

 

4. The same thing as #3 but shift click on all three columns

 

- doesn't work because it results in the default sort of the existing data.

 

I've ran out of ideas. Please help! 😞

 

 

Edit: I found the solution on YouTube! Link: https://youtu.be/RDXvpE3V5m0?si=NA5s7BVR5Xu9yy6g

1 ACCEPTED SOLUTION
Anonymous
Not applicable

8 REPLIES 8
Anonymous
Not applicable

I found the solution on YouTube! Link: https://youtu.be/RDXvpE3V5m0?si=NA5s7BVR5Xu9yy6g

HarishKM
Memorable Member
Memorable Member

@Anonymous Hey,
Kindly use cluster column chart for your requirmeent.

Please refer below example for your reference.

HarishKM_0-1744367567912.png


I am following below steps.

select Cluster column chart

drag your cat and sub cat to x axis

drag your QTY measure to value.

select three dot on right side - select sort by QTY then select ASC order to sort as per your requirment.

 

Thanks

Harish M

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Add snapshop for your reference

Anonymous
Not applicable

Hi @HarishKM 

  • Unfortunately this will not work for me because if you were to set the subcategories quantities to be different, for example if bb is more than aa but bb2 is less than aa1, the categories would be sorted according to the quantities so the sub category of bb2 will be before aa1, causing the category not sorted by quantity
barritown
Solution Sage
Solution Sage

Hi again,

 

Here is an advanced version of this approach which should work in more complicated scenarios.

The idea is to create a measure which generates a sorting order value consisting of two parts: the whole part is responsible for sorting categories, the decimal part - for sorting subcategories.

 

barritown_0-1744362612903.png

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

Anonymous
Not applicable

Hi! Sorry for the incredibly late reply. It doesn't quite work somehow. But good news, i found a video online that solves my problem. Thank you so much for your time !! 

Anonymous
Not applicable

Hi @barritown

Let me try this and update here again soon. Thank you 

barritown
Solution Sage
Solution Sage

Hi @Anonymous,

I can offer you to create a sorting option like this one:

barritown_0-1744296174899.png

With your real data it can be more complicated.

Once done, you can add it to Tooltips, then it will be available among the sorting options.

If you drill down, you will get what you want with subcategories:

barritown_1-1744296548745.png

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

Anonymous
Not applicable

Hi @barritown 

Thanks for this. However, as you've expected, my data is a bit more complicated, hence I'm unable to get the expected result. Thank you very much for your work book as reference too.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.