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: 
Not applicable

Get Multiple Previous Years with Set Expression

Hi,

I have a report with a simple List Chart that sums Net Value. I also have Calendar_Year as a field, so that multiple years can be selected. And I have this expression to calculate the previous selected year:

sum({$<Calendar_Year={"$(=ONLY(Calendar_Year)-1)"}>} DocumentRows.LineTotal)

But this won't work when multiple years are selected.

Do you know a way to calculate the sum of the previous years when multiple years are selected?

Kind Regards

Julian

1 Solution

Accepted Solutions
Not applicable
Author

Hi Julian,

You can use this:

sum({$<Calendar_Year={"$(=max(Calendar_Year)-1)"}>} DocumentRows.LineTotal)

or if you want the sum of all previous years try this:

sum({$<Calendar_Year={"<=$(=max(Calendar_Year)-1)>=$(=min(Calendar_Year)-1)"}>} DocumentRows.LineTotal)

Hope this helps

Regards!

View solution in original post

2 Replies
Not applicable
Author

Hi Julian,

You can use this:

sum({$<Calendar_Year={"$(=max(Calendar_Year)-1)"}>} DocumentRows.LineTotal)

or if you want the sum of all previous years try this:

sum({$<Calendar_Year={"<=$(=max(Calendar_Year)-1)>=$(=min(Calendar_Year)-1)"}>} DocumentRows.LineTotal)

Hope this helps

Regards!

Not applicable
Author

Thanks a lot Gabriela!

What I was looking for was your second anwer and it works like a charm!!

Kind Regards