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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

getting last 7 years

Hi to all,

how can i generate last 7 years in a Single variable  dynamically. Either in macro or editscript.

Based on Current Year it should calculate last 7 Years.

Current Year =2011 , then last 7 years should display, as same below.

Ex:

      ABCD

      2010

      2009

      2008

      2007

      2006

      2005

      2004

If Current Year =2012 then last 7 years is 2011 to 2003.

How can i work on this ?

Regards

Venkat

2 Replies
swuehl
MVP
MVP

Hi,

I am not quite sure what you want to achieve.

Do you want to set a (comma separated) list of year values to a variable or use a certain period (last 7 years) for limiting the display / calculation of a dimension / expression?

From your post, I would assume the first; is Current year another variable /selection or do you want to use the current timestamp?

If you want the latter, I would use set analysis and limit for example dimension Year to the last 7 years.

e.g. sum( {$<Year = {">= $(=year(now())-8) <= $(=year(now())-1)"}>} Sales )

[Be aware that you might need to set other time dimensions to empty selection if needed within the set, depending your data model]

(Besides I think the last seven year for current year 2012 should be 2011 to 2005, right?)

Regards,

Stefan

Not applicable
Author

Hi Swuehl,

Pls can you see the attached sample QVW file.

What you mentioned in last line is correct. I need to display those years in a listbox.

I need to display last 7 years in a single variable.

Regards

Venkat