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.
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?
GJUDGE Great that it works!
For comparisson with the start of the year you can use this measure:
Connect on Linkedin
- v-xiaotang4 years agoCommunity Support
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.
- jppv204 years agoSolution Sage
GJUDGE Hi Gary. Are you sure you are not filtering anything? It gives me this result:
Jori
If I answered your question, please mark it as a solution to help other members find it more quickly.
Connect on Linkedin - jppv204 years agoSolution Sage
GJUDGE I think that would be the problem indeed. In that case try:
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())-1&&MONTH('Master Data'[Reporting Period])=MONTH(MAXX('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 - GJUDGE4 years agoHelper II
jppv20 Hi Jori, still providing me the same result - only the total output from the current month with no deduction for the start of the year 😞. I've managed to correct by applying the following, but not sure if this will work going forward into other years!
Yearly MW 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',('Master Data'[Reporting Period])=MINX('Master Data','Master Data'[Reporting Period])))ReturnOutput-OutputLastPeriod