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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Link 2 tables with closest lower date

Hi everybody,

I have 2 tables: 1 is a cost table and 1 is an order table(see below)

Cost tableOrder table
ItemStdCostStartdateItemOrderNumOrderDate
shoe2.5520080923shirt1020081215
shoe2.5720090101shoe1120090228
shoe2.620090601shoe1220090306
shirt3.3320081201pants1320090611
shirt3.420090201shirt1420090612
pants4.120090213shoe1520090701
pants4.220090610pants1620090701
pants4.320090730pants1720090815
pants4.420091101shirt1820091123


I need to retrieve the stdcost of an item for each orderNum.

The cost table works this way: The stdCost of a shoe is 2.55 between 20080923 and 20083112.

It is 2.6 between 20090601 and today.

The resulting table should look like below:

Resulting table
ItemOrderNumOrderDateStdCost
shirt10200812153.33
shoe11200902282.57
shoe12200903062.57
pants13200906114.2
shirt14200906123.4
shoe15200907012.6
pants16200907014.2
pants17200908154.3
shirt18200911233.4


I can't find any example in the forum that would show me how to do this.

Thanks in Advance.

Chris

6 Replies
Not applicable
Author

Where/how is you source data stored?

Not applicable
Author

Nigel,

It's on an AS400.

Not applicable
Author

OK, I have no experience with that so I'm not sure I can help.

If it was SQL then I would recommend doing the Join in the SQL Select statement and loading a single table into QVW, unless there's a good reason not to do this.

Either way, I believe you are going to need to sort the problem out at the load script side, not on the front end.

Not applicable
Author

Nigel,

I would be interested to learn how to do this with 2 excel tables too( look at a working example).

Thanks

Not applicable
Author

If your Cost table has an item number associated with the item I would link the two tables by item number. So you could link the item number from the order to the item number in your cost table.  Being your data resides on an AS/400 (as ours does). I would have the data sent from the AS/400 as a CSV text file and import them into QlikView. This is what we do. The AS/400 developer just would need to do a simlpe CL program and send the files to the IFS where QlikView can get the CSV files.

Something like this:

CPYTOIMPF FROMFILE(COSTTABLE) +

                           TOSTMF('AS400Files/COSTTABLE.TXT') +

                           MBROPT(*REPLACE) FROMCCSID(37) +

                           STMFCODPAG(*PCASCII) RCDDLM(*CRLF)

CHGAUT OBJ('/AS400Files/COSTTABLE.TXT') USER(YOURUSER) +

                       DTAAUT(*RX) OBJAUT(*ALL)

Then you can manipulate the data however you need. But like I said (having worked in a reatil envionrment before) - linking by an Item number is going to be your best bet.

calvindk
Creator III
Creator III

I would add in the enddate to the cost table and then do intervalmatch.

Best wishes