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
Lisa_2021
Helper II
Helper II

How to use SUM function with variable? SUM only works with column. I don't want to use SUMX

Hello, This problem has baffled me to no end.  I'm hoping someone can help.  

Lisa_2021_1-1649942466318.png

 

 

Much appreciated!!!!
Lisa

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Lisa_2021 ,

 

You could create the following calculated columns.

final_sales = SWITCH(TRUE(),'table 1'[customer]="C",20,'table 1'[customer]="D",15,'table 1'[customer]="E",50,'table 1'[sales])
total final sales = CALCULATE(SUM('table 1'[final_sales]),ALL('table 1'))
weight* = DIVIDE([final_sales],[total final sales])

vstephenmsft_0-1650351024367.png

 

 

You could check more details from my attachment.

 

 

 

Best Regards,

Stephen Tao

 

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 @Lisa_2021 ,

 

You could create the following calculated columns.

final_sales = SWITCH(TRUE(),'table 1'[customer]="C",20,'table 1'[customer]="D",15,'table 1'[customer]="E",50,'table 1'[sales])
total final sales = CALCULATE(SUM('table 1'[final_sales]),ALL('table 1'))
weight* = DIVIDE([final_sales],[total final sales])

vstephenmsft_0-1650351024367.png

 

 

You could check more details from my attachment.

 

 

 

Best Regards,

Stephen Tao

 

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

@Lisa_2021 ,

Try something like this

 

return

Sumx(Table1, final_sales)

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

Hello amitchandak!

I tried and I'm getting different #s for each customer with SUMX.

What am I doing wrong?  Thanks!

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.