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

Announcements
Q&A with Qlik - Qlik Cloud Migration: Questions about migrating to Qlik Cloud? Catch the latest replay!
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 .

Labels (1)
1 Solution

Accepted Solutions
Nicole-Smith
MVP
MVP

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
MVP
MVP

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