Forum Discussion

mmar141's avatar
mmar141
Frequent Visitor
3 years ago
Solved

Finding the difference two sources from a single column.

Hello,

I need help with a measure to find the differences between two sources.   

 

My table looks like this

 

 

And I'd need the measure to calculate the difference

like this

 

Can anyone help?

  • mmar141 add following measures:

     

    Sum Value = SUM ( Table[Value] )
    
    Sum Source A = CALCULATE ( [Sum Value], Table[Source] = "A" )
    Sum Source B = CALCULATE ( [Sum Value], Table[Source] = "B" )
    
    Sum Diff = [Sum Source B] - [Sum Source A] 

     

    Use these measures in the visual and you should be good to go.

4 Replies

  • mmar141 add following measures:

     

    Sum Value = SUM ( Table[Value] )
    
    Sum Source A = CALCULATE ( [Sum Value], Table[Source] = "A" )
    Sum Source B = CALCULATE ( [Sum Value], Table[Source] = "B" )
    
    Sum Diff = [Sum Source B] - [Sum Source A] 

     

    Use these measures in the visual and you should be good to go.

    • mmar141's avatar
      mmar141
      Frequent Visitor

      I get the error 

      The syntax for 'Value' is incorrect. (DAX(Sum Value = SUM ( 'Table'[Value] )Sum Source A = CALCULATE ( [Sum Value], 'Table'[Source] = "A" )Sum Source B = CALCULATE ( [Sum Value], 'Table'[Source] = "B" )Sum Difference = [Sum Source B] - [Sum Source A] )).

      Difference = Sum Value = SUM ( 'Table'[Value] )

      Sum Source A = CALCULATE ( [Sum Value], 'Table'[Source] = "A" )
      Sum Source B = CALCULATE ( [Sum Value], 'Table'[Source] = "B" )

      Sum Difference = [Sum Source B] - [Sum Source A]
    • mmar141's avatar
      mmar141
      Frequent Visitor

      Wow.  I was overthinking this.  Much appreciated!