Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
MindaugasBacius
Partner - Specialist III
Partner - Specialist III

Generating quarters

Hello,

I have a table like this:

IDStartEnd
12016-05-01
22016-08-012017-01-31
32016-04-012016-09-31

The idea is to generate the quarter intervals in between Start and End dates.

If field End is empty then the End should be the closest end of the quarter made from Start and Today() dates.

The result should be like this:

IDStartEnd
12016-05-012016-07-31
12016-08-012016-10-31
12016-11-012017-01-31
22016-08-012016-10-31
22016-11-012017-01-31
32016-04-012016-06-30
32016-07-012016-09-31

Thank you!

1 Solution

Accepted Solutions
sunny_talwar

Slight change to fix the end dates:

Table:

LOAD ID,

  Date(AddMonths(Start, +(IterNo()*3)-3)) as Start,

  Date(AddMonths(Start, +(IterNo()*3))-1) as End

While AddMonths(Start, +(IterNo()*3)) < If(Len(Trim(End)) = 0, AddMonths(Today(), 3), AddMonths(End, 3));

LOAD ID,

    Start,

    End

FROM

[https://community.qlik.com/thread/238899]

(html, codepage is 1252, embedded labels, table is @1);

View solution in original post

3 Replies
sunny_talwar

May be this?

Table:

LOAD ID,

  Date(AddMonths(Start, +(IterNo()*3)-3)) as Start,

  Date(AddMonths(Start, +(IterNo()*3))) as End

While AddMonths(Start, +(IterNo()*3)) < If(Len(Trim(End)) = 0, AddMonths(Today(), 3), AddMonths(End, 3));

LOAD ID,

    Start,

    End

FROM

[https://community.qlik.com/thread/238899]

(html, codepage is 1252, embedded labels, table is @1);

sunny_talwar

Slight change to fix the end dates:

Table:

LOAD ID,

  Date(AddMonths(Start, +(IterNo()*3)-3)) as Start,

  Date(AddMonths(Start, +(IterNo()*3))-1) as End

While AddMonths(Start, +(IterNo()*3)) < If(Len(Trim(End)) = 0, AddMonths(Today(), 3), AddMonths(End, 3));

LOAD ID,

    Start,

    End

FROM

[https://community.qlik.com/thread/238899]

(html, codepage is 1252, embedded labels, table is @1);

tresesco
MVP
MVP

May be like this?

LOAD ID,

    Start,

    QuarterEnd(Start,IterNo()-1) as End

FROM

[https://community.qlik.com/thread/238899]

(html, codepage is 1252, embedded labels, table is @1)

while if(len(trim(End))=0,QuarterEnd(Start,IterNo()-1) <= QuarterEnd(today())

,QuarterEnd(Start,IterNo()-1) <= End);

Untitled.png