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: 
rchiew604
Contributor
Contributor

Default to current year but enable user to select from year dropdown list as well

Have a gauge chart on my dashboard that does the following calculation:

 sum({<[Ledger Type]={'BA'}   
  ,Source={'F0902'}
        ,[JDE.Year] = {$(=$(vV_CurrentYear))}
        >}Amount/100)

vV_CurrentYear = Year(Today()) so the chart is currently defaults to the current year.

However, we'd also like to enable the users to select other year from the 'Year' filter pane. Please note, they can only select one single year from the filter but not multiple years.

Please let me know how to achieve this via set analysis.

Thanks in Advance.

21 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Yes, it's a bit if a trick that it works.  What you really want is the max JDE.Year but no later than today.  When nothing or more than 1 JDE.Year is selected, [JDE.Year] is returning null because there is only one value.  So it uses today(). 

It will however break if more than one JDE.Year is selected. It actually should have a max() in there:

 ,[JDE.Year] = {$(=RangeMin(max([JDE.Year]),Year(today())))}

 

-Rob

rchiew604
Contributor
Contributor
Author

You are absolutely right.

By adding 'max' to the expression, it is now only return the most recent year data even if I select multiple years.

Learning something new. Thank You!