Forum Discussion
SSS
8 years agoHelper I
Difference between consecutive values in a Measure
Good Afternoon, I need help with an issue regarding the difference between two consecutive values in a Measure. I've made a measure that allows me to SUM the values of number of operations fo...
- 8 years ago
Try this
Cumulative= IF ( HASONEVALUE ( Consulta1[Date] ), SUMX ( FILTER ( ALL ( Consulta1[Date] ), Consulta1[Date] <= VALUES ( Consulta1[Date] ) && MONTH ( Consulta1[Date] ) = MONTH ( VALUES ( Consulta1[Date] ) ) ), [Difference] ) )
Anonymous
8 years agoNot applicable
SSS,
Create a new table using DAX below.
Table = SUMMARIZE(Consulta1,Consulta1[Date],"Medida",[Medida])
In the new table, create Index column, Difference column and Cumulative measure.
Index = CALCULATE(COUNT('Table'[Date]),ALL('Table'),'Table'[Date]<=EARLIER('Table'[Date]))
Difference = var previous=CALCULATE(FIRSTNONBLANK('Table'[Medida],'Table'[Medida]),FILTER('Table','Table'[Index]-1=EARLIER('Table'[Index]) )) return IF(ISBLANK(previous),BLANK(),'Table'[Medida]-previous)
Cumulative = IF(SUM('Table'[Difference])=BLANK(),BLANK(),CALCULATE(SUM('Table'[Difference]),FILTER(ALL('Table'),'Table'[Date]<=MAX('Table'[Date]))))
Regards,
Lydia