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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
kevbrown
Creator II
Creator II

Rolling 3 months in Script

I need my script to only pull in data from the current month and the previous 2 months, how do i do that?

1 Solution

Accepted Solutions
kevbrown
Creator II
Creator II
Author

Just needed to be this - Where Date>=(MonthStart(Today(), -2)

Thanks

View solution in original post

8 Replies
sunny_talwar

May be like this:

TempTable:

LOAD Date(MonthStart(Today(), -2)) as Date

AutoGenerate Today() - MonthStart(Today(), -2);

FactTable:

LOAD AllFields,

          DateField

FROM....

Where Exists(Date, DateField);

kevbrown
Creator II
Creator II
Author

Thank sunny but that just gave me 01/06/2016

juraj_misina
Partner Ambassador Affiliate
Partner Ambassador Affiliate

You can try combination of sorting, peek and rangesum.

LOAD

     Month,

     Value,

     RangeSum(Value, Peek(Value, -1), Peek(Value, -2))     as 3M_Cumulative

From Source

Order By Month;

Anonymous
Not applicable

maybe use a where clause like:

where datefield >=addmonths(monthstart(today()),-2)

kevbrown
Creator II
Creator II
Author

Just needed to be this - Where Date>=(MonthStart(Today(), -2)

Thanks

sunny_talwar

Good to use Where Exists if you are looking to do an optimized QVD load

kevbrown
Creator II
Creator II
Author

Ok, it's a fairly small load so should be ok but if it begins to slow I'll look to add it

sunny_talwar

Sounds good