Forum Discussion
Same Period Prior Year with Dynamic Date Range
- 5 years ago
Hi, garynorcrossmmc
According to your description and sample pictures, I can clearly understand your requirement, I’ve also created some data to achieve your need, you can try my steps:
This is part of the test data I created based on your description:
- I created two measures like this:
Sum of HIRECNT = SUM('HR AGG_WORKFORCEEVENT'[HIRECNT])Sum of HIRECNT (1 Year Prior) = var _max=MAX('HR DIM_MONTH'[Date]) var _min=MIN('HR DIM_MONTH'[Date]) return CALCULATE( SUM('HR AGG_WORKFORCEEVENT'[HIRECNT]), FILTER(ALL('HR AGG_WORKFORCEEVENT'), [Date]>=DATE(YEAR(_min)-1,MONTH(_min),DAY(_min))&& [Date]<=DATE(YEAR(_max)-1,MONTH(_max),DAY(_max))&& [Date (End of month)]=FORMAT(MAX([Date]),"MMMM")&" "&YEAR(MAX([Date]))-1))- Then I created a “date between” slicer and a table chart to place them like this:
And as you can see from the last picture, you can get what you want with the correct data displayed.
You can download my test pbix file below
If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.
How to Get Your Question Answered Quickly
Thank you very much!
Best Regards,
Community Support Team _Robert Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, garynorcrossmmc
According to your description and sample pictures, I can clearly understand your requirement, I’ve also created some data to achieve your need, you can try my steps:
This is part of the test data I created based on your description:
- I created two measures like this:
Sum of HIRECNT = SUM('HR AGG_WORKFORCEEVENT'[HIRECNT])Sum of HIRECNT (1 Year Prior) =
var _max=MAX('HR DIM_MONTH'[Date])
var _min=MIN('HR DIM_MONTH'[Date])
return
CALCULATE(
SUM('HR AGG_WORKFORCEEVENT'[HIRECNT]),
FILTER(ALL('HR AGG_WORKFORCEEVENT'),
[Date]>=DATE(YEAR(_min)-1,MONTH(_min),DAY(_min))&&
[Date]<=DATE(YEAR(_max)-1,MONTH(_max),DAY(_max))&&
[Date (End of month)]=FORMAT(MAX([Date]),"MMMM")&" "&YEAR(MAX([Date]))-1))
- Then I created a “date between” slicer and a table chart to place them like this:
And as you can see from the last picture, you can get what you want with the correct data displayed.
You can download my test pbix file below
If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.
How to Get Your Question Answered Quickly
Thank you very much!
Best Regards,
Community Support Team _Robert Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Success! Thank you, v-robertq-msft!!!