Forum Discussion
Lisa_2021
Helper II
4 years agoHow 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.
Much appreciated!!!!
Lisa
- Anonymous4 years ago
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])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.
3 Replies
- amitchandak
Super User
- Lisa_2021
Helper II
Hello amitchandak!
I tried and I'm getting different #s for each customer with SUMX.
What am I doing wrong? Thanks!
- AnonymousNot 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])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.