Forum Discussion

fxz9's avatar
fxz9
Frequent Visitor
8 years ago
Solved

table Calculate for sum field operation

Source Data Example

 

itemamount
AA10
AA5
BB3
BB3

 

after powerBI by summrize by item (categray)

 item       Sum

AA15
BB

6

 

 

I hope power bi can show the result as Sum(AA)-Sum(BB)

In tableau ,I can using table calucation funcion to do that.

 

AA15
BB6
AA-BB9

 

I'm not sure how to implement an operation for sum measure.

 

 
  • Hi fxz9,

     

    Power BI doesn't support that. As a workaround, you can show the difference in an extra column. Please refer to below measure:

    AA-BB =
    CALCULATE (
        SUM ( Table1[amount] ),
        FILTER ( ALL ( Table1 ), Table1[item] = "AA" )
    )
        - CALCULATE (
            SUM ( Table1[amount] ),
            FILTER ( ALL ( Table1 ), Table1[item] = "BB" )
        )

     

    Best regards,

    Yuliana Gu

2 Replies

  • v-yulgu-msft's avatar
    v-yulgu-msft
    Icon for Microsoft Employee rankMicrosoft Employee

    Hi fxz9,

     

    Power BI doesn't support that. As a workaround, you can show the difference in an extra column. Please refer to below measure:

    AA-BB =
    CALCULATE (
        SUM ( Table1[amount] ),
        FILTER ( ALL ( Table1 ), Table1[item] = "AA" )
    )
        - CALCULATE (
            SUM ( Table1[amount] ),
            FILTER ( ALL ( Table1 ), Table1[item] = "BB" )
        )

     

    Best regards,

    Yuliana Gu

    • fxz9's avatar
      fxz9
      Frequent Visitor

      Thanks for you replay