Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have a table like this:
ID | Start | End |
---|---|---|
1 | 2016-05-01 | |
2 | 2016-08-01 | 2017-01-31 |
3 | 2016-04-01 | 2016-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:
ID | Start | End |
---|---|---|
1 | 2016-05-01 | 2016-07-31 |
1 | 2016-08-01 | 2016-10-31 |
1 | 2016-11-01 | 2017-01-31 |
2 | 2016-08-01 | 2016-10-31 |
2 | 2016-11-01 | 2017-01-31 |
3 | 2016-04-01 | 2016-06-30 |
3 | 2016-07-01 | 2016-09-31 |
Thank you!
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);
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);
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);
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);