'Using SUMX to calculate difference between versions

Not sure how to go about this but I feel like it is possible. Basically I have a set of data that is similar to what is shown below.

What I would like to be able to do is count how many contracts in each program had a change of greater than +-300.

For example, in this dataset, Project A Contract 1 changed by -400 and Project B Contract 2 changed by -400 so both Project A and Project B would have a count of 1. Project A Contract 2 and Project B Contract 1 should not be counted because they did not change.

In my mind there is a way to do this with SUMX or such but I don't quite understand how to do this.

My thought is something on a take on this but really need some guidance. Not sure how to get it down to the 'Contract' level.

Calculate(SUMX(DataTable,Amount),Version="Current") - Calculate(SUMX(DataTable,Amount),Version="Prior")

Much appreciated

enter image description here



Solution 1:[1]

Hi for this you have to create a summarized table and then form there you have to calculate the difference.

Measure = 
var tab = ADDCOLUMNS(SUMMARIZE('DataTable','DataTable'[Project],'DataTable'[Contract]),"sumval",sum('DataTable'[Amount]))
var cur = CALCULATE(SUMX(tab,[sumval]),'DataTable'[Version]="Current")
var priv = CALCULATE(SUMX(tab,[sumval]),'DataTable'[Version]="Prior")
return cur-priv

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 AmilaMGunawardana