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

how to merge 2 table

Spoiler
hi all,

sorry for my simple question but i'm a beginner and probably someone has already asked this.

I have 2 tables with a field in common.

I would like to merge these table but if there is no correspondence in the second table, it must add a blank field.

For example:

TABLE A    
KeyField1Field2Field3 
1alfa452 
3beta237 
4gamma75 
5delta233 
TABLE B    
KeyField4   
1milano   
4torino   
     
FINAL TABLE   
KeyField1Field2Field3Field4
1alfa452milano
3beta237 
4gamma75torino
5delta233 

Could you please help me? 

Thanks in advance and regards

Mauro


3 Replies
lironbaram
Partner - Master III
Partner - Master III

load * 

from Table A 

join 

load * 

from Table B

dwforest
Specialist II
Specialist II

Note this only works when the tables share a common key and field name; Qlik automatically joins on field name

Rodj
Luminary Alumni
Luminary Alumni

Hi @mauvasco62 ,

The other guys have already helped you with what is probably the easiest answer. Another approach to consider in this instance is to use a mapping load. This is essentially what people often call a "lookup" of a value. This approach is often preferred in circumstances where a value is being mapped to another one, such as mapping an ID field to a description as it is more efficient that a join and can be simpler. It won't help you in scenarios where you want to add more than one field at a time from 

// Create the mapping table

map1:

mapping load Key, Field4

Table B;

// Apply the map to add the new column to your table A

TableA:

Load *,

ApplyMap('map1', Key, null()) as Field4

Table A;

 

Note that I've used a default value of null() for Field4 in cases where there isn't a Key field match, but you can put whatever you like in there as a default value.

And just to confuse matters you could play with forced concatenation of the tables, but that's probably not what you are after in this instance.

Cheers,

Rod