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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mojganmeibodi19
Regular Visitor

sorting legend based on two criteria

I have a simple dataset that contains each supplier's sale in each year. I made a bar chart with years in the x axis and suppliers' sale on the y axis and used supplier company as legend.

Screenshot (11).png
I want to sort the legend (suppliers) in each bar (year) based on the total sales of that supplier in that specific year.
I can sort them by all-time total sales of suppliers, but I dont know how to do this sorting in each year.

6 REPLIES 6
josef78
Memorable Member
Memorable Member

Try Ribbon chart, and set transparency on connectors....

@mojganmeibodi19 I think @josef78 's proposal is the best answer.

lbendlin
Super User
Super User

Not possible in the standard visual.  May not even be possible in Deneb unless @dm-p has an idea.

Vega and Vega-Lite don't have sorting capabilities for more than one field using standard language constructs, but you can use transforms and window functions to create fields that dictate a sort order that you can then sort by.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Could you layer the individual columns as separate marks with their own sort order? Or would you have to know the number of columns/marks beforehand?

Whatever the layer, if they share the same encoding channel, Vega will likely resolve them to the same scale (and sort). Your best bet would be to use a window transform to generate a numeric order based on grouping and sorting of multiple fields in the dataset and then sort on that.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

March 2024 PBI Gallery Image

Power BI Monthly Update - March 2024

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