Forum Discussion
QLB
3 years agoFrequent Visitor
Compare value with selected value
Hi ! I need to display data on a histogram for the last 3 years, knowing that the user has selected the max year. I have a dataset "FACTS" showing sales by product for each year. I al...
AilleryO
3 years agoMemorable Member
Hi,
It could have been easier with real dates, since we could work with time Intelligence, but if you don't have a real date in your data, you can calculate the previous year.
Measure =
Var SelectedYear = MAX ( [Year] )
Var PrevYear = SelectedYear-1
Var PrevPrevYear = PrevYear-1
RETURN
CALCULATE( YourMeasure , Year IN { SelectedYear , PrevYear , PrevPrevYear } )
Shoud do the trick, do not hesitate to tell us if it works..
It could be used as well with a FILTER or CALCULATETABLE...