Forum Discussion
Doing division based on multiple years
- 5 years ago
Have you tried a measure expression like this? This should work in a card. If you use it in a table/matrix/other visual, you may need to add other terms to the CALCULATE.
A divided by B Prev 3 yrs =
VAR thisyear =
YEAR ( TODAY () )
VAR result =
CALCULATE (
DIVIDE ( SUM ( Table[A] ), SUM ( Table[B] ) ),
Table[Year] >= thisyear - 3
&& Table[Year] <= thisyear - 1
)
RETURN
resultPat
Have you tried a measure expression like this? This should work in a card. If you use it in a table/matrix/other visual, you may need to add other terms to the CALCULATE.
A divided by B Prev 3 yrs =
VAR thisyear =
YEAR ( TODAY () )
VAR result =
CALCULATE (
DIVIDE ( SUM ( Table[A] ), SUM ( Table[B] ) ),
Table[Year] >= thisyear - 3
&& Table[Year] <= thisyear - 1
)
RETURN
result
Pat
- Anonymous5 years agoNot applicable
Thank you mahoneypat
This logic worked well enough to allow me to continue to troubleshoot further. I am indeed using this in a table. The result returns slightly skrewed numbers than I would expect, but this isn't a problem with the DAX logic.
So close, yet so far!