Forum Discussion
Anonymous
6 years agoNot applicable
Calculate difference between values per category at irregularly spaced dates
Hi PowerBi Community, Background: I'm just learning PowerBI (it's a great tool!) and hoping you all can help me. I have found posts on the form about regularly spaced time interval comparisons (YoY,...
- 6 years ago
Hi Anonymous ,
We can create measure use following formula to meet your requirement:
LastChange = VAR LastDay = MAX ( 'Table'[Date] ) VAR LastTwoday = CALCULATE ( MAX ( 'Table'[Date] ), FILTER ( 'Table', [Date] < LastDay ) ) RETURN CALCULATE ( SUM ( 'Table'[MyValue] ), FILTER ( 'Table', 'Table'[Date] = LastDay ) ) - CALCULATE ( SUM ( 'Table'[MyValue] ), FILTER ( 'Table', 'Table'[Date] = LastTwoday ) )If use your index column, this formula can be more easier:
LastChangeUseIndex = CALCULATE ( SUM ( 'Table'[MyValue] ), FILTER ( 'Table', 'Table'[IndexCategory] = MAX ( 'Table'[IndexCategory] ) ) ) - CALCULATE ( SUM ( 'Table'[MyValue] ), FILTER ( 'Table', 'Table'[IndexCategory] = MAX ( 'Table'[IndexCategory] ) - 1 ) )
BTW, pbix as attached.Best regards,
Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
6 years agoNot applicable
Hi lc_finance & v-lid-msft ,
Thank you both so much for the explanations and example files! You helped immensily :smileyhappy:
lc_finance
6 years agoSolution Sage
Hi Anonymous ,
I'm very glad it helped you!
Best of luck for your analysis
LC