The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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
Solved! Go to Solution.
I found the solution on YouTube! Link: https://youtu.be/RDXvpE3V5m0?si=NA5s7BVR5Xu9yy6g
I found the solution on YouTube! Link: https://youtu.be/RDXvpE3V5m0?si=NA5s7BVR5Xu9yy6g
@junmin Hey,
Kindly use cluster column chart for your requirmeent.
Please refer below example for your reference.
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
Hi @HarishKM
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.
Best Regards,
Alexander
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 !!
Hi @junmin,
I can offer you to create a sorting option like this one:
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:
Best Regards,
Alexander
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.