Forum Discussion

jstanten's avatar
jstanten
New Member
3 months ago
Solved

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 ...
  • cengizhanarslan's avatar
    3 months ago

    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.