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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
jstanten
New Member

Dual Sorting for Stacked Bar Chart

I have a stacked bar chart with the x axis sorted by date, in ascending order. However, i want the stacked bar chart legend to be sorted by value, not by alphabetical order. There seems to be an out of box limitation to sorting an axis by date while sorting a legend by value. This limitation is inexplicable, but that just seems to be the way it is.

 

I've tried using the "sort by column" feature in Column Tools, but results in a circular dependency.

 

To avoid that error I've also tried creating a new "sort table", adding a relationship to my primary fact table, and the using the "sort by column" feature to work around the circular dependency error. No luck.

Is there really no viable path for this?

1 ACCEPTED SOLUTION
cengizhanarslan
Super User
Super User

There is no native workaround that fully solves this. You could create a calculated column or Power Query column that assigns a sort rank based on total value across all dates:

LegendRank =
RANKX (
    ALL ( 'Table'[LegendField] ),
    CALCULATE ( SUM ( 'Table'[Value] ) ),
    ,
    DESC,
    DENSE
)

Then sort your legend field by this LegendRank column via Column tools → Sort by column. This will not be dynamic per date (it sorts by overall total), but it gets the highest-value categories to the top of the stack consistently.

_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn | Follow on Medium
AI-assisted tools are used solely for wording support. All conclusions are independently reviewed.

View solution in original post

5 REPLIES 5
jstanten
New Member

Thank you all for your replies! I appreciate the suggestions and support. While this doesn't directly resolve the challenge, it gives me a number of usable work-arounds that I think our team will find helpful.

 

Thank you all very much!

 

Justin

v-achippa
Community Support
Community Support

Hi @jstanten,

 

Thank you for reaching out to Microsoft Fabric Community.

 

Thank you @ryan_mayu@DanieleUgoCopp and @cengizhanarslan for the prompt response.

 

As we haven’t heard back from you, we wanted to kindly follow up to check if the responses provided by the user's for the issue worked? or let us know if you need any further assistance.

 

Thanks and regards,

Anjan Kumar Chippa

cengizhanarslan
Super User
Super User

There is no native workaround that fully solves this. You could create a calculated column or Power Query column that assigns a sort rank based on total value across all dates:

LegendRank =
RANKX (
    ALL ( 'Table'[LegendField] ),
    CALCULATE ( SUM ( 'Table'[Value] ) ),
    ,
    DESC,
    DENSE
)

Then sort your legend field by this LegendRank column via Column tools → Sort by column. This will not be dynamic per date (it sorts by overall total), but it gets the highest-value categories to the top of the stack consistently.

_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn | Follow on Medium
AI-assisted tools are used solely for wording support. All conclusions are independently reviewed.
DanieleUgoCopp
Solution Supplier
Solution Supplier

Hello,
If the proejct permit it, you can create a legend with another visual, like a table, and try to link it to the chart, if you want to make disappear something with filter or whatver is needed,
or creating a ranking column in the model for a fixed order,
or to use a custom visual downloading some visual exterally
Best Regards,
Daniele

ryan_mayu
Super User
Super User

@jstanten 

If you want to sort by calcaulated column, that may cause  circular dependency error. You have to do that in Power Query

Could you pls provide some sample data and expected output?





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

Proud to be a Super User!




Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

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.