I have a table like below with three columns: Year
, Type1
, and Type2
. I need a measure that can flag a change in Type2
for each Type1
over year. A measure that gives a column like Change in Type2
below:
For example, this measure could give 1
if Type2
in Type1
has changed next year, and it gives 0
if Type2
stays the same so that at the end I can have this table:
Is there any measure that can calculate this? Many thanks in advance
You can do the change in Type2
by comparing versus the previous year:
Change in Type2 =
VAR CurrType2 = SELECTEDVALUE ( Table1[Type2] )
VAR CurrYear = SELECTEDVALUE ( Table1[Year] )
VAR PrevType2 =
CALCULATE (
SELECTEDVALUE ( Table1[Type2] ),
ALL ( Table1[Type2] ),
Table1[Year] = CurrYear - 1
)
RETURN
IF ( ISBLANK ( PrevType2 ), BLANK(), IF ( CurrType2 = PrevType2, 0, 1 ) )
The sum of the change is then pretty simple:
Change Sum = SUMX ( VALUES ( Table1[Type1] ), [Change in Type2] )
Thank you very much for taking your time. It worked nicely!