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: 
manoranjan_d
Specialist
Specialist

latest and pervious year

Hi

I having list of year from 2010 to 2016

in my qvd i want to retrieve the latest year and pervious year only

so i need 2016 and 2015 only

Labels (1)
12 Replies
sunny_talwar
MVP
MVP

May be this:

Max(Year) and

Max(Year) - 1

Mark_Little
Luminary
Luminary

Hi,

Add a where clause in your loader.

from Data.QVD

WHERE Year >= 2015;

Mark

manoranjan_d
Specialist
Specialist
Author

how declare this in the variable

sunny_talwar
MVP
MVP

If you want them as values, then use triggers, else just give the above as definition to your variable

manoranjan_d
Specialist
Specialist
Author

how to achieve this in the if loop condtion in the qvd generator

Mark_Little
Luminary
Luminary

Hi,

I would need more information on your script and the loop in questions as you may be able to set it in variable and then increment it if needed. depend a lot of the script and what exactly you're trying to achieve

Mark

manoranjan_d
Specialist
Specialist
Author

i have field called year

now if i want to call that field only with current year and previous year

Anil_Babu_Samineni
MVP
MVP

I am not sure, What is mean of Variable.

Perhaps this

SET vCurrYear = Max(Year);

SET vPrevYear = Max(Year) - 1;

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Mark_Little
Luminary
Luminary

Ok, but you mentioned a loop?

If you want it to be dynamic you could add a variable

LET vYear = YEAR(ADDYEARS(TODAY(),-1));

TABLE:

LOAD

     *

Resident Location

WHERE Year >= $(vYear);

Mark