Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

last but one year

Hi i have  requirement like displaying sales of  last but one year not current year-1.

year field is like 2014 and 2011 and 2008 like this not in order .

1 Solution

Accepted Solutions
Nicole-Smith

You can find the second highest year by using:

max(Year, 2)

So to sum sales, something like:

sum({<Year={$(=max(Year, 2))}>}Sales)

View solution in original post

2 Replies
Nicole-Smith

You can find the second highest year by using:

max(Year, 2)

So to sum sales, something like:

sum({<Year={$(=max(Year, 2))}>}Sales)

hic
Former Employee
Former Employee

In the script, in the master calendar you should define a flag for last year:

  If( Year(Date) = Year(Today())-1, 1, 0) as IsLastYear,

Then you can use this in a Set Analysis expression:

  Sum ( {$<IsLastYear={1}>} Amount )

HIC