Forum Discussion

Poisedon's avatar
Poisedon
Frequent Visitor
7 years ago
Solved

Sum by category

Hi all,

In the Query I need to sum values by "Client" but I can't use "Group by..." because it deletes other columns. I also want to put 0 for other rows with same Client (can't delete because in other columns i have data). See image for understand.

 

 

 

  • Poisedon

     

    Try a new calculated column like

     

    Column =
    IF (
        [Value]
            = CALCULATE ( MAX ( Table1[Value] ), ALLEXCEPT ( Table1, Table1[Client] ) ),
        CALCULATE ( SUM ( Table1[Value] ), ALLEXCEPT ( Table1, Table1[Client] ) ),
        0
    )
    

2 Replies

  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    Community Champion

    Poisedon

     

    Try a new calculated column like

     

    Column =
    IF (
        [Value]
            = CALCULATE ( MAX ( Table1[Value] ), ALLEXCEPT ( Table1, Table1[Client] ) ),
        CALCULATE ( SUM ( Table1[Value] ), ALLEXCEPT ( Table1, Table1[Client] ) ),
        0
    )
    
    • Poisedon's avatar
      Poisedon
      Frequent Visitor

      It works if i take the column with no aggregation, but in my table I've sum of values, so values are wrong in this case :/