Forum Discussion
Measure difference of two last rows in matrix visual (reference to another measure(s))
- 4 years ago
Hi, navafolk ;
Try it.
MTD diff = var _max=CALCULATE(MAX('Table'[source name.date]),ALL('Table')) var _min=CALCULATE(MAX('Table'[source name.date]),FILTER(ALL('Table'),[source name.date]<_max)) return IF(MAX([Date])>EOMONTH(MAX('Table'[source name.date]),-2), IF(ISINSCOPE('Table'[source name.date]), SUM([Amount]), CALCULATE(SUM([Amount]),FILTER('Table',[source name.date]=_max))-CALCULATE(SUM([Amount]),FILTER('Table',[source name.date]=_min))))The final output is shown below:
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
navafolk , date should be joined with a date table
then you can have measures like
MTD = CALCULATE(SUM(Table[Value),DATESMTD('Date'[Date]))
last MTD = CALCULATE(Sum(Table[Value]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
diff= [MTD] -[Last MTD]
final measure = if(isinscope (Table[Source.name.date]), [MTD], [Diff])
https://www.kasperonbi.com/use-isinscope-to-get-the-right-hierarchy-level-in-dax/
Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA