Forum Discussion

Lisa_2021's avatar
Lisa_2021
Icon for Helper II rankHelper II
4 years ago
Solved

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.  

 

 

Much appreciated!!!!
Lisa

 

3 Replies

    • Lisa_2021's avatar
      Lisa_2021
      Icon for Helper II rankHelper II

      Hello amitchandak!

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

      What am I doing wrong?  Thanks!

  • Anonymous's avatar
    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])

     

     

    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.