Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Query only the past 12 months of data

I have the below backend script but would like to add in a rolling 12 month pull for column StartDate in the Where clause. I would imagine this would be fairly easy but can't figure it out. Any help would be appreciated.

***Only extract 12 months of data. Take current date minus 12 months.

AvgDays:

LOAD

CLT_ AS CLTID,
Avg([FIRST_DAYS])AS Avg_Days

FROM $(vPath_QVDs)MainTable.qvd(qvd)

Where NOT IsNull(FIRST_DAYS)
AND REASSIGNED  = 'NO'

GROUP BY
CLT

1 Solution

Accepted Solutions
Digvijay_Singh

May be like this--


LOAD

CLT_ AS CLTID,
Avg([FIRST_DAYS])AS Avg_Days

FROM $(vPath_QVDs)MainTable.qvd(qvd)

Where NOT IsNull(FIRST_DAYS)
AND REASSIGNED  = 'NO'

AND StartDate>Addmonths(Today(1),-12)

GROUP BY
CLT

View solution in original post

7 Replies
Sergey_Shuklin
Specialist
Specialist

Hello, John!

Can you, please, explain what it's mean "rolling 12 month pull"? You need to iterate this script twelve times? Or calculate a total sum for year? Or smth else?

Anonymous
Not applicable
Author

I have updated my title.

I only want to pull 12 months of data. Rolling from today's date. Something like below in Oracle.

AND STARTDATE > add_months(TRUNC(SYSDATE), -12) 

Anil_Babu_Samineni

Is this you are doing in Qlik / Oracle?

In Qlik, May be this?

Sum({<STARTDATE = {'>= $(=Date(AddMonths(Max(SYSDATE),-12),'DateFormatHere') <=$(=Date(Today(),'DateFormatHere'))'}>}Sales)

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
Anonymous
Not applicable
Author

MY QLIKVIEW SCRIPT BELOW. NOW I WOULD LIKE TO ADD A FILTER THAT ONLY RETURN THE PAST 12 MONTHS OF DATA FROM A COLUMN CALLED STARTDATE

LOAD

CLT_ AS CLTID,
Avg([FIRST_DAYS])AS Avg_Days

FROM $(vPath_QVDs)MainTable.qvd(qvd)

Where NOT IsNull(FIRST_DAYS)
AND REASSIGNED  = 'NO'

GROUP BY
CLT

Sergey_Shuklin
Specialist
Specialist

Usually helps this filter:

Where StartDate>Addmonths(today(),-12)

Digvijay_Singh

May be like this--


LOAD

CLT_ AS CLTID,
Avg([FIRST_DAYS])AS Avg_Days

FROM $(vPath_QVDs)MainTable.qvd(qvd)

Where NOT IsNull(FIRST_DAYS)
AND REASSIGNED  = 'NO'

AND StartDate>Addmonths(Today(1),-12)

GROUP BY
CLT