Forum Discussion

dasari2020's avatar
dasari2020
Frequent Visitor
6 years ago
Solved

Compute difference between Subtotals

Hi ,

Can some one guide me on how to calculate  the difference between two subtotals in DAX?

 

 
 
  • Right, again, no sample data so can't be specific. Hint.

     

    But, in general, you want to do this. Take a look at your visual and see how it is aggregated. Let's say it is by "Thing". You want to create a virtual table using a VAR that emulates this and your columns. Then use SUMX and basic math. Something like this:

    Subtotal Difference =
      VAR __Table = 
        SUMMARIZE(
          'Table',
          [Thing],
          "2019",SUM([2019),
          "2020",SUM([2020)
        )
    RETURN
      SUMX(__Table,[2019]) - SUMX(__Table,[2020])

     

4 Replies