Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Trey
Contributor II
Contributor II

Limit Bar Chart to 5 years

Hi - I have a simple bar chart that has "Years" for the dimension and "Number of incidents" as the measure.

My expression for years is =(Year([DOL - NOTIFICATION]))

My data for Years goes back to 2003. Currently, this expression shows all years dating back to 2003. I would like to limit this bar chart to the current year plus the last four. I'm having trouble finding an expression that will do this. 

 

Any ideas?

Thanks

3 Replies
chaorenzhu
Creator II
Creator II

use this set expression in your measure:

{<years={">$(=max(year)-5)"}>}

Trey
Contributor II
Contributor II
Author

Thanks, but when I use   ={<year={">$(=max(year)-5)"}>}  it says there is garbage in the expression after =. Thoughts?

chaorenzhu
Creator II
Creator II

What expression are you using to calculate "Number of incidents"? Say it's sum(num), then just write =sum({<year={">$(=max(year)-5)"}>} num)