Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

how to fetch last 12 months data.

HI

In my QVW file having an "Test" table, in that having data from 2006 to current day date(i;e;04-07-2011).

"CapDate" is the field in my table having the data like this i.e; from "01-01-2006 12:13:15" to "04-07-2011 12:13:15"

Now when i load the "Test" table then i need to have the data of  only last 12 months from current day onwards.

How can i achieve this.

Regards

Venkat

1 Reply
nagaiank
Specialist III
Specialist III

The following sample script shows how you can extract one year data from the table of data for several years. Hope this helps you write the script for your application.

LET vStartDate = Num(Date#('01/01/2006','MM/DD/YYYY'));

LET vEndDate   = Num(Date#('12/31/2011','MM/DD/YYYY'));

AllData:

    LOAD Date($(vStartDate) + IterNo() - 1) as Date

    ,Ceil(rand()*100) as Sales

    AutoGenerate 1

    While $(vStartDate) + IterNo() <= $(vEndDate);

RequiredData:

NoConcatenate LOAD * Resident AllData Where Date >= AddYears(Today(),-1) and Date <= Today();

DROP Table AllData;