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: 
marco_puccetti
Partner - Creator
Partner - Creator

How to save latest selection

Hello, I need to save in a variable the value of the latest selection (year) for the computation of a sum on a previous year.

Anybody knows how to do this?

Thanks

Marco

2 Replies
marcus_sommer

You could use max() for this directly within the expression:

sum({< year = {"$(=max(year))"}>} value)

vs.

sum({< year = {"$(=max(year)-1)"}>} value)

- Marcus

Anonymous
Not applicable

you could do what Marcus suggested and not use variable at all. but if you want to create variables for other purposes, then create variables using Ctrl+Alt+V and click on Add.

1. vMaxYear and expression will be =max(year)

2. vPrevYear and expression as = max(year) -1