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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

link with date range

Hi,

I have a question with linking 3 tables.

Debtor(1.200 records)

DebtorCodeDebtornamePriceCode
1John2
2Pierre3
3Smith2

Invoice(60.000 records)

InvoiceCodeDebtorCodeInvoiceDate
1201-01-2013
2302-03-2013

Price(400 records)

PriceCodeStartDateEndDatePricePrice per 100Price per 1000
101-01-201303-04-20131090800
201-02-201305-05-20131295850
301-05-201310-10-201416120900
201-01-201331-01-2013101001000

What I need to know is the following

InvoiceCodeDebtornameInvoiceDatePricePrice per 100Price per 1000
1Pierre01-01-201316120900
2Smith02-03-20131295850

Normally i would just do this with an If statement in the expression.

But when i tried it this time it used about 12GB of RAM. not very usefull....

Do you know some way to make it possible to create this overview?

1 Solution

Accepted Solutions
MK_QSL
MVP
MVP

Debtor:

Load * Inline

[

  DebtorCode, Debtorname, PriceCode

  1, John, 2

  2, Pierre, 3

  3, Smith, 2

];

Invoice:

Load

  InvoiceCode,

  DebtorCode,

  Date(Date#(InvoiceDate,'DD-MM-YYYY')) as InvoiceDate

Inline

[

  InvoiceCode, DebtorCode, InvoiceDate

  1, 2, 01-01-2013

  2, 3, 02-03-2013

];

Left Join (Invoice) Load * Resident Debtor;

Drop Table Debtor;

Price:

Load

  PriceCode,

  Date(Date#(StartDate,'DD-MM-YYYY')) as StartDate,

  Date(Date#(EndDate,'DD-MM-YYYY')) as EndDate,

  Price,

  [Price per 100],

  [Price per 1000]

Inline

[

  PriceCode, StartDate, EndDate, Price, Price per 100, Price per 1000

  1, 01-01-2013, 03-04-2013, 10, 90, 800

  2, 01-02-2013, 05-05-2013, 12, 95, 850

  3, 01-05-2013, 10-10-2014, 16, 120, 900

  4, 01-01-2013, 31-01-2013, 10, 100, 1000

];

IntervalMatch(InvoiceDate, PriceCode)

Load StartDate, EndDate, PriceCode Resident Price;

Inner Join (Invoice) Load * Resident Price;

Drop Table Price;

View solution in original post

7 Replies
anbu1984
Master III
Master III

Can you show us what you have tried?

MK_QSL
MVP
MVP

Debtor:

Load * Inline

[

  DebtorCode, Debtorname, PriceCode

  1, John, 2

  2, Pierre, 3

  3, Smith, 2

];

Invoice:

Load

  InvoiceCode,

  DebtorCode,

  Date(Date#(InvoiceDate,'DD-MM-YYYY')) as InvoiceDate

Inline

[

  InvoiceCode, DebtorCode, InvoiceDate

  1, 2, 01-01-2013

  2, 3, 02-03-2013

];

Left Join (Invoice) Load * Resident Debtor;

Drop Table Debtor;

Price:

Load

  PriceCode,

  Date(Date#(StartDate,'DD-MM-YYYY')) as StartDate,

  Date(Date#(EndDate,'DD-MM-YYYY')) as EndDate,

  Price,

  [Price per 100],

  [Price per 1000]

Inline

[

  PriceCode, StartDate, EndDate, Price, Price per 100, Price per 1000

  1, 01-01-2013, 03-04-2013, 10, 90, 800

  2, 01-02-2013, 05-05-2013, 12, 95, 850

  3, 01-05-2013, 10-10-2014, 16, 120, 900

  4, 01-01-2013, 31-01-2013, 10, 100, 1000

];

IntervalMatch(InvoiceDate, PriceCode)

Load StartDate, EndDate, PriceCode Resident Price;

Inner Join (Invoice) Load * Resident Price;

Drop Table Price;

sundarakumar
Specialist II
Specialist II

Have u linked these table in the back end?

-Sundar

MarcoWedel

correction sample data

PriceCodeStartDateEndDatePricePrice per 100Price per 1000
101-01-201303-04-20131090800
201-02-201305-05-20131295850
301-05-201210-10-201416120900
201-01-201331-01-2013101001000
MarcoWedel

Hi,

one possible solution could be to include the relevant price data in the invoice table:

QlikCommunity_Thread_134144_Pic1.JPG.jpg

Debtor:

LOAD *

FROM [http://community.qlik.com/thread/134144] (html, codepage is 1252, embedded labels, table is @1);

Invoice:

LOAD *

FROM [http://community.qlik.com/thread/134144] (html, codepage is 1252, embedded labels, table is @2);

Price:

LOAD *

FROM [http://community.qlik.com/thread/134144] (html, codepage is 1252, embedded labels, table is @5);

Left Join (Invoice)

LOAD Distinct

  DebtorCode,

  PriceCode

Resident Debtor;

Left Join (Invoice)

IntervalMatch (InvoiceDate, PriceCode)

LOAD StartDate,

    EndDate,

    PriceCode

Resident Price;

Left Join (Invoice)

LOAD StartDate,

    EndDate,

    PriceCode,

    Price as price,

    [Price per 100] as [price per 100],

    [Price per 1000] as [price per 1000]

Resident Price;

DROP Fields PriceCode, StartDate, EndDate From Invoice;

hope this helps

regards

Marco

vikasmahajan

you can interval match for achieving the same find attache mt of  demo will help you to achieve the same.

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
Not applicable
Author

Ok so, the intervalmatch solution is the one I needed, it works, in theory that is. But after carefull analysis of the original datasource a problem occurred. Apparantly in the Price table there are overlapping ranges, so for 1 invoice i have 280 possible prices, we will have to solve that first, in the datasource. I will mark the first 2 correct answers, thank you all for the help. I really appreciate it.