Forum Discussion
Comparing Periods in the same table
- 4 years ago
Hi GJUDGE
You can use Edate() function to get last period, for example,
Last Period = var _currentDate=MAX('table'[date]) var _lastDate=EDATE(_currentDate,-1) return CALCULATE(SUM('table'[Output]),'table'[date]=_lastDate)Kindly note: Edate() function has some limitations,
If you can't use Edate() on some occasions, you can try this measure,
Last Period = var _maxDate=MAX('table'[date]) var _lastDate=DATE(YEAR(_maxDate),MONTH(_maxDate)-1,1) return CALCULATE(SUM('table'[Output]),'table'[date]=_lastDate)Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
In that case this measure should work:
Jori
If I answered your question, please mark it as a solution to help other members find it more quickly.
Connect on Linkedin
jppv20 The measure is giving me the total of the output column as opposed to the output difference column. I have copied my measure below with actual table names etc., if you can see any errors within this?
- GJUDGE4 years agoHelper II
jppv20 Sorry, it actually works! I still had a filter on!! Thank you for your help! Could you help me understand how would I modify this measure to then compare the start of the year (with a fixed date rather than reporting period included?)
to current month?
- jppv204 years agoSolution Sage
GJUDGE Great that it works!
For comparisson with the start of the year you can use this measure:
Start of year Change =var Output = CALCULATE(SUM('Master Data'[Projected Capacity (MW)]),FILTER('Master Data','Master Data'[Reporting Period]=MAXX('Master Data','Master Data'[Reporting Period])))var OutputLastPeriod = CALCULATE(SUM('Master Data'[Projected Capacity (MW)]),FILTER('Master Data',YEAR('Master Data'[Reporting Period])=YEAR(TODAY())&&MONTH('Master Data'[Reporting Period])=MONTH(MINX('Master Data','Master Data'[Reporting Period]))))ReturnOutput-OutputLastPeriodJoriIf I answered your question, please mark it as a solution to help other members find it more quickly.
Connect on Linkedin