Forum Discussion
Use a variable on "Filters on this virtual"
- 1 year ago
Hi kobkabnaja ,
Because you're evaluating each year line by line, the current max item will always be equal to the selected item, therefore you'll get a true result always.
This should work instead:Selected Years = VAR _HowManyYrs = 4 VAR _MaxYear = CALCULATE(MAX('DATE'[Year]), ALL('DATE')) RETURN IF( SELECTEDVALUE('DATE'[Year]) <= _MaxYear - _HowManyYrs, 0, 1)Then on your visual, don't forget to filter for where value is 1:
Hi kobkabnaja ,
Because you're evaluating each year line by line, the current max item will always be equal to the selected item, therefore you'll get a true result always.
This should work instead:
Selected Years =
VAR _HowManyYrs = 4
VAR _MaxYear = CALCULATE(MAX('DATE'[Year]), ALL('DATE'))
RETURN
IF( SELECTEDVALUE('DATE'[Year]) <= _MaxYear - _HowManyYrs, 0, 1)
Then on your visual, don't forget to filter for where value is 1:
Hi hnguy71 ,
Apologies for the delayed response, and thank you so much for this solution—it works perfectly! I will take some time to go through the commands and will reach out if any questions come up.
For anyone else looking for a solution, I highly recommend checking this out. @hnguy71 has also provided an example for using a disconnected filter, which I found useful and plan to incorporate into future projects. Kudos to you, hnguy71 !
Cheers,
K