Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Join tables based on date range

I am new to Qlikview and am having trouble with this load script. Would greatly appreciate some help.


My master data source (Table1) comprises 113 columns but my focus is one field named DtOfSale. My fiscal year data source (Table2) comprises FYDayNum which is a number 0 through 12, and the corresponding LastBusDayMinus4 and LastBusDayPlus4 dates, as shown below:


   

FYDayNumLastBusDayMinus4LastBusDayPlus4
008/27/201809/06/2018
109/24/201810/04/2018
210/25/201811/06/2018
311/26/201812/06/2018
412/25/201801/04/2019
501/25/201902/06/2019
602/22/201903/06/2019
703/25/201904/04/2019
804/24/201905/06/2019
905/27/201906/06/2019
1006/24/201907/04/2019
1107/25/201908/06/2019
1208/26/201909/05/2019


The results that I need are the FYDayNum value based on the range in which my field DtOfSale in Table 1 falls. For example, if DtOfSale is 9/26/2018 then the FYDayNum returned should be 1 because it falls within the LastBusDayMinus4 of 09/24/2018 and LastBusDayPlus4 of 10/04/2018..

Here is what I have so far:


[Table1]:

LOAD

     DtOfSale

FROM

[..\..\..\..\MainData.xlsx]

(ooxml, embedded labels);

[Table2]:

LOAD

      FYDayNum,

      LastBusDayMinus4,

      LastBusDayPlus4

FROM

[..\..\..\..\FiscalMapping.xlsx]

(ooxml, embedded labels, table is LastBusinessDayOfFY);


tabMatch:

IntervalMatch(dateid)

LOAD FYDayNum, DtOfSale

1 Solution

Accepted Solutions
vishsaggi
Champion III
Champion III

May be try below:

[Table1]:

LOAD

     DtOfSale

FROM

[..\..\..\..\MainData.xlsx]

(ooxml, embedded labels);

[Table2]:

LOAD

      FYDayNum,

      LastBusDayMinus4,

      LastBusDayPlus4

FROM

[..\..\..\..\FiscalMapping.xlsx]

(ooxml, embedded labels, table is LastBusinessDayOfFY);


INNER JOIN

tabMatch:

IntervalMatch(DtOfSale)

LOAD LastBusDayMinus4, LastBusDayPlus4

Resident [Table2];

View solution in original post

5 Replies
MK9885
Master II
Master II

Can you provide sample XL file data?

Anonymous
Not applicable
Author

Yes, below is sample data from the Table1 data source -- I just noticed that I put "dateid" in the my first post. The field is DtOfSale not dateid:

     

recordidDtOfSalesalesfiscal_quarterfiscal_year
17/2/2018192.928412018
27/2/201890.5266732018
37/2/20181070.26912018
47/2/20188927.08142019
54/2/20181.1899932018
64/2/20183232018
74/2/201814.42942018
84/2/20184.04685332018
97/2/201811.6122018
107/2/2018519.549322018
117/2/2018163.399822018
124/2/201846.0686732018
134/2/20182833.33342018
144/2/20185219.45122019
1510/1/20151532.85912016
168/1/20178.1838812018
1710/1/2015954.040332016
185/2/201612119.842017
1911/3/20141000042015
2011/3/20141015022015
2110/1/201333.2834112014
2210/1/2013666.666722014
237/2/20184.19833332018
247/2/2018504.389532018
257/2/20181.33333342018
268/1/20163499.11732017
277/1/2014333.333342014
vishsaggi
Champion III
Champion III

May be try below:

[Table1]:

LOAD

     DtOfSale

FROM

[..\..\..\..\MainData.xlsx]

(ooxml, embedded labels);

[Table2]:

LOAD

      FYDayNum,

      LastBusDayMinus4,

      LastBusDayPlus4

FROM

[..\..\..\..\FiscalMapping.xlsx]

(ooxml, embedded labels, table is LastBusinessDayOfFY);


INNER JOIN

tabMatch:

IntervalMatch(DtOfSale)

LOAD LastBusDayMinus4, LastBusDayPlus4

Resident [Table2];

Anonymous
Not applicable
Author

Thanks! That worked and the FYDayNum that it returns is correct.