Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
cawestelaken
Contributor II
Contributor II

Joining new records based on existing table

Hello,

I've got a table 'Facts' that I've Concatenate loaded another table onto.
I'd like to join another table with this concatenated table but not the original table.

Original Facts:

Key1Key2CountryName
11NLJan
11NLPiet
12NLPiet
21NLKlaas
31NLPeter
32NLPeter
41BEKlaas
52BEJan
53BEJan
62USAPiet


To concatenate:

Key1Key2Flagged
11Y
21Y
31Y
41Y
52Y
62Y

 

Concatenated table:

Key1Key2CountryNameFlagged
11NLJan 
11NLPiet 
12NLPiet 
21NLKlaas 
31NLPeter 
32NLPeter 
41BEKlaas 
52BEJan 
53BEJan 
62USAPiet 
11  Y
21  Y
31  Y
41  Y
52  Y
62  Y

 

I've been trying for a better way to combine the two tables, such as doing a join. Sadly in the full table it is possible for 2 records to completely be the same except for 1 value. (In the example for instance this is "Name") thus this'd result in a record being flagged when it shouldn't be. I've yet to find a better solution, but as far as I am aware there is none. (If you've got any advice, I'll show my ultimately desired result at the bottom of this question.)

To join:

Key1Key2Open
11Y
21Y
52Y
62Y

 

Desired result:

 

Key1Key2CountryNameFlaggedOpen
11NLJan  
11NLPiet  
12NLPiet  
21NLKlaas  
31NLPeter  
32NLPeter  
41BEKlaas  
52BEJan  
53BEJan  
62USAPiet  
11  YY
21  YY
31  Y 
41  Y 
52  YY
62  YY


My idea was to do so as follows:

Left Join Load
Key1,
Key2,
Open
Resident To Join
Where IsNull(Country);

Sadly this gives me this error:
"Field 'Country' not found"

Now I assume this is because there is no 'Country' in 'To Join'.

Anyone know how to fix this?

Yours sincerely,
Casper Westelaken

Ultimately desired result:

I've tried to achieve this. The second record in the example (1,1,NL,Piet) is what's making this problematic.

Key1Key2CountryNameFlaggedOpen
11NLJanYY
11NLPiet  
12NLPiet  
21NLKlaasYY
31NLPeterY 
32NLPeter  
41BEKlaasY 
52BEJanYY
53BEJan  
62USAPietYY
4 Replies
OmarBenSalem

toConcatenate:
load * Inline [
Key1, Key2, Flagged
1, 1, Y
2, 1, Y
3, 1, Y
4, 1, Y
5, 2, Y
6, 2, Y
];

left Join(toConcatenate)
toJoin:
load * Inline [
Key1, Key2, Open
1, 1, Y
2, 1, Y
5, 2, Y
6, 2, Y
];


Concatenate(toConcatenate)
Fact:
load * Inline [
Key1, Key2, Country, Name
1, 1, NL, Jan
1, 1, NL, Piet
1, 2, NL, Piet
2, 1, NL, Klaas
3, 1, NL, Peter
3, 2, NL, Peter
4, 1, BE, Klaas
5, 2, BE, Jan
5, 3, BE, Jan
6, 2, USA, Piet
];

 

result:

Capture.PNG

OmarBenSalem

 
cawestelaken
Contributor II
Contributor II
Author

Essentially you're saying that I need to try to load it the other way around?
OmarBenSalem

yes Smiley Tongue