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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Creating Last 6/12/18/24 Months

Guys,

I have this field [Claim Close Date] that is my date field, set day-by-day. I want to create a field that gets the last 6 months, for example: we are in april/2014, i want to get all days from october/2013 - march/2014 ; I want that for last 12 months (march/2013 ~ march/2014), and I want the same for the last 18 months and the last 24 months.

Can you guys script for me a way out of that?

Labels (1)
1 Solution

Accepted Solutions
maxgro
MVP
MVP

if I understand

you can add some flag in a tabel associated to your date

LET Start = num(makedate(2012,1,1));

LET End = num(makedate(2014,12,1));

LET NumOfDays = End - Start + 1;


Date_src:

LOAD

$(Start) + Rowno() -1 as DateId

AUTOGENERATE $(NumOfDays);

ClaimCloseDateFlag:

LOAD

DateId as [Claim Close Date],

if(DateId >= AddMonths(MonthStart(today()), -6) and DateId <= monthstart(today())-1, 1, 0) as Flag6Month

// similar for Flag12,,,,,,,18.....2$

RESIDENT Date_src;

Drop Table Date_src;

View solution in original post

3 Replies
yduval75
Partner - Creator III
Partner - Creator III

I think you have to create two fields : start date and end date.
Then, you have to use the interval match function

maxgro
MVP
MVP

if I understand

you can add some flag in a tabel associated to your date

LET Start = num(makedate(2012,1,1));

LET End = num(makedate(2014,12,1));

LET NumOfDays = End - Start + 1;


Date_src:

LOAD

$(Start) + Rowno() -1 as DateId

AUTOGENERATE $(NumOfDays);

ClaimCloseDateFlag:

LOAD

DateId as [Claim Close Date],

if(DateId >= AddMonths(MonthStart(today()), -6) and DateId <= monthstart(today())-1, 1, 0) as Flag6Month

// similar for Flag12,,,,,,,18.....2$

RESIDENT Date_src;

Drop Table Date_src;

Not applicable
Author

This works just perfect, thank you. We use alot the numbers from last 6 months and 12 months. Thank you very much!