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
Winniethewinner
Helper IV
Helper IV

Add Total to clustered column chart - sorting issue

Hello everyone, 

 

I'm trying to add a total bar to the clustered column chart. 

Here is my Fact Table:

Winniethewinner_0-1716583125855.png

 

Here is the Channel Table created and I set up the relationship between the two tables using Channel: 

Winniethewinner_3-1716583366955.png

And below is the YoY% measure I created and trying to add to the visual: 

YoY % = IF(SELECTEDVALUE('Channel Table'[Channel])="TOTAL",CALCULATE(DIVIDE(SUM(Fact_Table[TOTAL CY])-SUM(Fact_Table[TOTAL LY]),SUM(Fact_Table[TOTAL LY])),ALL('Channel Table'[Channel])),DIVIDE(SUM(Fact_Table[TOTAL CY])-SUM(Fact_Table[TOTAL LY]),SUM(Fact_Table[TOTAL LY])))
Winniethewinner_2-1716583331340.png

However, I'd like the TOTAL to be displayed as the last column, and when I sort the Channel by Order, the TOTAL disappear from the visual: 

Winniethewinner_4-1716583442139.png
Winniethewinner_5-1716583462551.png

I'm not sure if it's a bug or I miss anything. Any suggestions would be appreciated. Thanks. 

1 ACCEPTED SOLUTION
kpost
Super User
Super User

result.PNG

Not sure what I did differently but perhaps you can reverse-engineer the .pbix file I attached, I simply re-created your tables and solved the problem from the bottom up.

 

Here's the measure I ended up using.

 

YoY % =
VAR SELECTED_VAL = SELECTEDVALUE('Channel Dimension'[Channel])
VAR CY = COALESCE(SUM('Fact'[TOTAL CY]), 0)
VAR LY = COALESCE(SUM(Fact[TOTAL LY]), 0)
VAR YOY = DIVIDE(CY - LY, LY, 0)
VAR YOY_TOT = CALCULATE(DIVIDE(
            COALESCE(SUM('Fact'[TOTAL CY]), 0) - COALESCE(SUM(Fact[TOTAL LY]), 0),
            COALESCE(SUM(Fact[TOTAL LY]), 0),
            0), ALL('Channel Dimension'))


RETURN

IF (selected_val ="TOTAL", YOY_TOT, YOY)
 
 
 

View solution in original post

2 REPLIES 2
kpost
Super User
Super User

result.PNG

Not sure what I did differently but perhaps you can reverse-engineer the .pbix file I attached, I simply re-created your tables and solved the problem from the bottom up.

 

Here's the measure I ended up using.

 

YoY % =
VAR SELECTED_VAL = SELECTEDVALUE('Channel Dimension'[Channel])
VAR CY = COALESCE(SUM('Fact'[TOTAL CY]), 0)
VAR LY = COALESCE(SUM(Fact[TOTAL LY]), 0)
VAR YOY = DIVIDE(CY - LY, LY, 0)
VAR YOY_TOT = CALCULATE(DIVIDE(
            COALESCE(SUM('Fact'[TOTAL CY]), 0) - COALESCE(SUM(Fact[TOTAL LY]), 0),
            COALESCE(SUM(Fact[TOTAL LY]), 0),
            0), ALL('Channel Dimension'))


RETURN

IF (selected_val ="TOTAL", YOY_TOT, YOY)
 
 
 

Brilliant, it works! 

 

btw I also found I should change my formula to:
YoY % = IF(SELECTEDVALUE('Channel Table'[Channel])="TOTAL",CALCULATE(DIVIDE(SUM(Fact_Table[TOTAL CY])-SUM(Fact_Table[TOTAL LY]),SUM(Fact_Table[TOTAL LY])),ALL('Channel Table'[Channel])),DIVIDE(SUM(Fact_Table[TOTAL CY])-SUM(Fact_Table[TOTAL LY]),SUM(Fact_Table[TOTAL LY])))

and then it works too. 

 

Thanks for your help!

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

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.