Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
grajmca_sgp123
Creator
Creator

last 12 months extraction in script

Hi,

I want to extract last 12 month data only by excluding current month.

for example for this month values should be from sep 2014 to aug 2015. how we can extract always last 12 months only in script level.


Fields Month and Years:

Month format:01,02,03.........

year format:2014,2015

7 Replies
alexandros17
Partner - Champion III
Partner - Champion III

Something like:

Load ....

Resident ....

Where year = Year(MonthStart(AddMonths(Today(),-12)))  and month = month(MonthStart(AddMonths(Today(),-12))) ;

let me know

sunilkumarqv
Specialist II
Specialist II

Let varMaxDate = Num(MakeDate(2014,9,1));

Load 

inyear(DateField, Monthstart($(varMaxDate)),-1) as Last12months


from datasoruce;

senpradip007
Specialist III
Specialist III

Try something like

Tab:

Load *

From <datasource>

where date >= Addyear(MonthEnd(Today()), -1);

Not applicable

Hi,

Load *

Resident

Where year = Year(MonthStart(AddMonths(Today(),-12)))  and month = month(MonthStart(AddMonths(Today(),-12))) <Tablename> ;

it might help u.

Anonymous
Not applicable

Hi Rajesh,

Table:
Load * , Max(date) as MaxDate;
Load *

year

month

MakeDate('year','month',1) as Date

Resident....

Let varMaxDate = peek('MaxDate',0,'Table');

Let v12months = Date(addmonths ('$(varMaxDate)',-12, 'DD-MM-YYYY');


Data

load *

Resident Table

where Date >= '$(v12months)'

Drop Table Table;

Regards

Neetha

sasiparupudi1
Master III
Master III

Try like this

t1:

load * Inline

[

year,month

2015,01

2015,02

2015,03

2015,04

2015,05

2015,06

2015,07

2015,08

2015,09

2014,01

2014,02

2014,03

2014,04

2014,05

2014,06

2014,07

2014,08

2014,09

2014,10

2014,11

2014,12

];

NoConcatenate

tab2:

load year,month Resident t1

where MakeDate(year,month,1)>addyears(addmonths(Today(1),-1),-1) and MakeDate(year,month,1)<addmonths(Today(1),-1);

malini_qlikview
Creator II
Creator II

Hi,

Please try the below, use can use the for loop either loading data from QVD or SQL,

For i=1 to 12

Target:

Load

Year,

Month,

MonthName(Addmonths(Today(),-$(i))) AS Month_Loaded

Resident Source

where

Year = Year(Addmonths(Today(),-$(i))) and Month=Num(Month(Addmonths(Today(),-$(i))));

Next