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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
pbernardy
New Member

Cluster Bar Chart - Variance - Sort by Absolute

Hey everyone,

 

I am trying to set up a dashboard for daily sales tracking.

As part of it, I want a clustered bar chart with the sales variance vs forecast/prior year by customer.

The problem is I got positive and negative figures and I got hundreds of customers. So I want the bar chart to be sorted by the absolute variance, so that I have the customers on top that shows the biggest variance (irrespective if it's positive or negative)

 

I already calcualted the "absolute variance" as a separate measure, but couldn't find a way to sort the chart in the way without adding the "absolute variance" in the visual as a second value on the x-axis.

 

Directionally the data looks like sth like this.

So I got the variance column (Sales_Var_vs_Fcst), the customer (Name), so the standard order of the visual would be like in the column (Order by Value). However, I would like to have it ordered by the target order column (Target Order), which is based on the absolute variance (Absolute)

 

 Sales_Var_vs_Fcst  Name Order By Value Absolute TARGET ORDER
                                     315,319 Customer 1                             1         315,3192
                                     176,220 Customer 2                             2         176,2205
                                     154,008 Customer 3                             3         154,0086
                                     152,948 Customer 4                             4         152,9487
                                     136,824 Customer 5                             5         136,8248
                                     133,069 Customer 6                             6         133,0699
                                       52,289 Customer 17                             7           52,28911
                                       52,232 Customer 18                             8           52,23212
                                       46,580 Customer 19                             9           46,58013
                                       42,980 Customer 20                           10           42,98014
-                                   100,000 Customer 124                           11         100,00010
-                                   200,000 Customer 125                           12         200,0004
-                                   250,000 Customer 126                           13         250,0003
-                             10,000,000 Customer 127                           14   10,000,0001

thanks for your help

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @pbernardy ,

I create a table as you mentioned.

vyilongmsft_0-1730098288010.png

Then I think you can create three measures and here are the DAX code.

Order By Value = 
RANKX (
    ALL ( 'Table' ),
    CALCULATE ( SUM ( 'Table'[Sales_Var_vs_Fcst] ) ),
    ,
    DESC,
    DENSE
)

vyilongmsft_1-1730099385974.png

Absolute =
IF (
    MAX ( 'Table'[Sales_Var_vs_Fcst] ) < 0,
    ABS ( MAX ( 'Table'[Sales_Var_vs_Fcst] ) ),
    MAX ( 'Table'[Sales_Var_vs_Fcst] )
)

vyilongmsft_2-1730099484746.png

Measure = 
RANKX(ALL('Table'), CALCULATE('Table'[Absolute]), , DESC, Dense)

vyilongmsft_3-1730099534915.png

 

 

Best Regards

Yilong Zhou

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

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @pbernardy ,

I create a table as you mentioned.

vyilongmsft_0-1730098288010.png

Then I think you can create three measures and here are the DAX code.

Order By Value = 
RANKX (
    ALL ( 'Table' ),
    CALCULATE ( SUM ( 'Table'[Sales_Var_vs_Fcst] ) ),
    ,
    DESC,
    DENSE
)

vyilongmsft_1-1730099385974.png

Absolute =
IF (
    MAX ( 'Table'[Sales_Var_vs_Fcst] ) < 0,
    ABS ( MAX ( 'Table'[Sales_Var_vs_Fcst] ) ),
    MAX ( 'Table'[Sales_Var_vs_Fcst] )
)

vyilongmsft_2-1730099484746.png

Measure = 
RANKX(ALL('Table'), CALCULATE('Table'[Absolute]), , DESC, Dense)

vyilongmsft_3-1730099534915.png

 

 

Best Regards

Yilong Zhou

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

amitchandak
Super User
Super User

@pbernardy , Create a measure and add that to the tooltip and now you can sort on that column,

 

If this does not help, please provide data and expected output as suggested by @Tahreem24 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Tahreem24
Super User
Super User

@pbernardy  Kindly explain your scenario with the help of sample dummy data.

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.