Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
mwallman
Creator III
Creator III

How to get all the dates in between start date and end date for each transaction?

Hi all,

I have two date fields. Example:

OrderIDValueStartDate
EndDate
110001/01/201613/01/2016
222.9924/02/201628/02/2016
334.9914/03/201619/03/2016
459.9917/01/201629/01/2016
587.9910/03/201613/03/2016

How can I generate a table that has all the possible dates between the start date and end date for each order?

Is there a script solution for this please?

5 Replies
sunny_talwar

May be this:

Table:

LOAD OrderID,

  Value,

  StartDate,

  EndDate,

  Date(StartDate + IterNo() - 1) as Date

While Date(StartDate + IterNo() - 1) <= EndDate;

LOAD OrderID,

    Value,

    StartDate,

    EndDate

FROM

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

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


Capture.PNG



swuehl
MVP
MVP

It may be needed to create a link table between Date / Mastercalendar and your Order table, to avoid duplication of facts:

Table:

LOAD OrderID,

    Value,

    StartDate,

    EndDate

FROM

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

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

DateOrderLink:

LOAD OrderID,

  Date(StartDate + IterNo() - 1) as Date

RESIDENT Table

While Date(StartDate + IterNo() - 1) <= EndDate;

See also

Creating Reference Dates for Intervals

mwallman
Creator III
Creator III
Author

Hi Sunny and everyone,

What if I wanted to exclude the startdate and enddate from the list?

sunny_talwar

May be this:

Table:

LOAD OrderID,

  Value,

  StartDate,

  EndDate,

  Date(StartDate + IterNo()) as Date

While Date(StartDate + IterNo()) < EndDate;

LOAD OrderID,

    Value,

    StartDate,

    EndDate

FROM

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

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


Capture.PNG

martinpohl
Partner - Master
Partner - Master

see attached