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 I'm happy to stick with the current solution for the time being. Will need to remember that at the start of a new year though! Can I ask you one other question - how would I write a simple measure to sum the output for the previous month (i.e. max period minus 1)?
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.