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: 
martijn
Contributor III
Contributor III

Join on multiple fields

Hi,

I'm new to Qlikview. In the past I've developed a BusinessObjects universe and reports. I want to recreate these reports in Qlikview. I've come to the problem that I want to join a table with an other table on more than one field. In BO the join is:

Table1.FreeIntField_01=Table2.artgrp OR Table1.FreeIntField_02=Table2.artgrp OR Table1.FreeIntField_04=Table2.artgrp OR Table1.FreeIntField_05=Table2.artgrp.

I've tried to solve this issue with an concatenate load on Table1 where I rename the fields to artgrp. I'm not sure if this is the right way to solve this issue. Can somebody give me an advise?

Thanks in advance,

Regards,

Martijn

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

There are probably a lot of different approaches. Which to take depends on your data and the MEANING of this join. Are fields 01, 02, 04, and 05 basically just an array? Why is 03 skipped?

On the surface at least, it looks similar to something we do here. A user can enter up to five defect codes on a particular item. In the source data, these are just separate columns in one row. In QlikView, we can turn these into multiple rows for a single column on a separate table. The items are linked to additional defect information through this new table.

So for example:

// Pretend these are your source data tables.
[Item Source Data]:
LOAD * INLINE [
Item, Status, Weight, Color, Defect1, Defect2, Defect3, Defect4, Defect5
...
];
[Defect Source Data]:
LOAD * INLINE [
Defect, Defect Severity, Defect Description
...
];

// This builds three linked tables from our two unlinked source tables.
[Item]:
LOAD Item, Status, Weight, Color
RESIDENT [Item Source Data]
;
[Item Defect]:
CROSSTABLE (Defect Sequence, Defect) // Crosstable makes one row per defect,
// keyed by Item and Defect Sequence = 'Defect1' etc.
// with the actual defect code in field "Defect"
LOAD Item, Defect1, Defect2, Defect3, Defect4, Defect5
RESIDENT [Item Source Data]
;
[Defect]:
NOCONCATENATE LOAD *
RESIDENT [Defect Source Data]
;

// Get rid of the source data.
DROP TABLES
[Item Source Data]
,[Defect Source Data]
;

View solution in original post

2 Replies
johnw
Champion III
Champion III

There are probably a lot of different approaches. Which to take depends on your data and the MEANING of this join. Are fields 01, 02, 04, and 05 basically just an array? Why is 03 skipped?

On the surface at least, it looks similar to something we do here. A user can enter up to five defect codes on a particular item. In the source data, these are just separate columns in one row. In QlikView, we can turn these into multiple rows for a single column on a separate table. The items are linked to additional defect information through this new table.

So for example:

// Pretend these are your source data tables.
[Item Source Data]:
LOAD * INLINE [
Item, Status, Weight, Color, Defect1, Defect2, Defect3, Defect4, Defect5
...
];
[Defect Source Data]:
LOAD * INLINE [
Defect, Defect Severity, Defect Description
...
];

// This builds three linked tables from our two unlinked source tables.
[Item]:
LOAD Item, Status, Weight, Color
RESIDENT [Item Source Data]
;
[Item Defect]:
CROSSTABLE (Defect Sequence, Defect) // Crosstable makes one row per defect,
// keyed by Item and Defect Sequence = 'Defect1' etc.
// with the actual defect code in field "Defect"
LOAD Item, Defect1, Defect2, Defect3, Defect4, Defect5
RESIDENT [Item Source Data]
;
[Defect]:
NOCONCATENATE LOAD *
RESIDENT [Defect Source Data]
;

// Get rid of the source data.
DROP TABLES
[Item Source Data]
,[Defect Source Data]
;

martijn
Contributor III
Contributor III
Author

Thanks!!!!. This was the solution I was looking for!