Forum Discussion
summing previous year while allowing current year filter power bi
- 5 years ago
Hi Anonymous ,
Put the Year of Date hierarchy in the slicer and select current year, it should work.
Attached a sample file in the below, hopes it could help.
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I cant lock the report to only this year and last year. I will need to allow users to be able to adjust the Date Slicer without impacting the calculation for the previous year.
Below was my custom measure attempt:
My Measure=
test1 = SUM('Engagement'[Engagement Gains])
var test =
CALCULATE('Engagement'[test1],SAMEPERIODLASTYEAR('Engagement Data'[Date].[Date]),ALLEXCEPT('Engagement Data','Engagement Data'[Type],'Engagement Data'[Type2]))
return
(sum('Engagement Data'[Engagement Gains])/test) -1
What I expect/want to see:
Year:
2021
Type Type2 Growth
A 1 50%
Slicer = Current year
What I'm getting:
Year:
2020 2021
Type Type2 Growth Type Type2 Growth
A 1 Infinity A 1 50%
Slicer = Current year
Conclusion: I need Slicer of Current year to work by removing the year 2020 from report and only showing year 2021
Hi Anonymous ,
Put the Year of Date hierarchy in the slicer and select current year, it should work.
Attached a sample file in the below, hopes it could help.
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous5 years agoNot applicable
This will work. Its does not allow for "Relative Dates" but, still functions by displaying single year while still doing previous year calcualtion. Also to avoid the infinity return for years that do not have a prior year I've update dax in measure with below.
Thank you for you aid.
Measure =VAR test =CALCULATE (SUM ( Engagement[Engagement Gains] ),SAMEPERIODLASTYEAR ( 'Engagement'[Date].[Date] ),ALLEXCEPT ( 'Engagement', 'Engagement'[Type], 'Engagement'[Type2] ))RETURNIF(test=BLANK()||test<0, 0,( SUM ( Engagement[Engagement Gains] ) / test ) - 1)