Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Limiting data displayed in bar chart to last 12 years

I have data spanning some years as follows:

Screen Shot 2015-12-11 at 21.09.32.png

I have generated the following bar chart with ActionYear (Approval Year) as dimension and with the following expression:

if(Rank(Count({$<ChemicalTypeCode={1}>} DISTINCT [FDA Trade Name])) <= 12, Count({$<ChemicalTypeCode={1}>} Distinct [FDA Trade Name]))

Screen Shot 2015-12-11 at 21.08.27.png

I had hoped to display the last 12 years only but my expression is taking the top 12.  How can i show the data for the last 12 years only?

Regards.

15 Replies
Anonymous
Not applicable
Author

Thank you Agustin, the first recommendation works and i get what i am looking for.  However i would have preferred this be dynamic as opposed to hard coded.

Anonymous
Not applicable
Author

Hi Sunny, this is the only expression.  Using Augustin's recommendation confirms what i had mentioned to you earlier on as follows:

Screen Shot 2015-12-11 at 21.59.00.png

I was however looking of  dynamic expression as opposed to a hard coded one.  Let me send the sample application

Not applicable
Author

Try with the same expression:

if(Rank(Count({$<ChemicalTypeCode={1}>} DISTINCT [FDA Trade Name])) <= 12, Count({$<ChemicalTypeCode={1}>}Distinct [FDA Trade Name]))


BUT ! Add a "Calculated Dimension" and use this expression:


if (  ActionYear > year(today) - 12 , ActionYear  )


In this way you have a dynamic solution! I think so!



Anonymous
Not applicable
Author

Hi Agustin, Many thanks, that works.  I had to change the expression there were missing two brackets on today like today() :

if (  ActionYear > year(today()) - 12 , ActionYear  )

Anonymous
Not applicable
Author

Thank you Sergio, your recommendation also works well.

Regards

Not applicable
Author

Alright, but this works you're welcome !

best regards!