Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Interval Match Question

We have two tables. One table has columns 'ID' and 'Invoice Date'. Another one has columns 'ID', 'Start Date', 'End Date', and 'Price'. The desired output is 'ID', 'Invoice Date', 'Price'. I know this could be done using interval match but having a hard time figuring out how. Any help is highly appreciated. Attached is sample data for your convenience.

Table 1:

Product IDInvoiceDate
A10/16/2014
B08/01/2014

Table 2:

Product IDStart DateEnd DatePrice
A06/01/201406/30/2014$200
A07/01/201408/30/2014$350
A09/01/201412/31/9999$400
B06/01/201406/30/2014$250
B07/01/201408/30/2014$240
B09/01/201412/31/9999$300

Desired Output:

Product IDInvoiceDatePrice
A06/02/2014$200
A07/20/2014$350
B06/20/2014$250
B09/26/2014$300
1 Solution

Accepted Solutions
anbu1984
Master III
Master III

7 Replies
Anonymous
Not applicable
Author

Hey,

PFA document would help you.

REgards,

Chinna.

Not applicable
Author

No Luck. How to fit in amount is confusing me. I would really appreciate if you can create a quick QVW with attached data and post it back. That will be very helpful in understanding it. Thanks in advance for helping.

JonnyPoole
Employee
Employee

I started to do the interval match, and the first two IDs work as expected.

But then i noticed some duplication in your data that don't match the desired results.

For example, for 1000E2USdd 16890-000 , you have two intervales for 9/1/2014-> 12/31/9999 with 2 different values. See below

Untitled.png

And when i check the desired result it doesn't quite make sense

Untitled.png

How did you associate 9/26/2014 to line 11 and 10/15/2014 to line 14 ?? 

Not applicable
Author

I see what you are saying.Makes sense! I have updated the datasheet and have simplified it a bit. Please use that instead. Thanks for helping !

anbu1984
Master III
Master III

Check this app

JonnyPoole
Employee
Employee

Ok - i still see an unexpected 'desired output' in your spreadsheet.

There are 2 records with invoice dates below

Capture2.PNG.png

To match those 2 records to specific intervals we have the following possible intervals for A and B

Capture3.PNG.png

According to the above    ID=A and InvoiceDate=10/16/2014  would map to    $400    and  ID=B and InvoiceDate=08/01/2014 would map to  240$  .  However your expected outcome is this ???

Capture4.PNG.png

When I applied the interval match in QlikView i got the expected result of

Capture1.PNG.png

If you agree with me,  below is the load script for this and attached is the QVW. The solution uses the 'extended' interval match syntax to not only match the interval but another identifier as well... in this case ID.

Invoices:

LOAD ID,

    Date(InvoiceDate) as InvoiceDate

FROM

(ooxml, embedded labels, table is [Table 1]);

StartEnds:

LOAD ID,

    Date([Start Date]) as [Start Date],

    Date([End Date]) as [End Date],

    Price

FROM

(ooxml, embedded labels, table is [Table 2]);

inner join IntervalMatch (InvoiceDate,ID) LOAD [Start Date], [End Date],ID Resident StartEnds;

hic
Former Employee
Former Employee

See also the QlikTech document about it: IntervalMatch and Slowly Changing Dimensions

HIC