Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
EAK
Contributor
Contributor

Combining two tables

Hi everyone

I have two tables with same field. I want just combine two tables below, I used concatanate but ıt creates new row.

I want to just keep number of lines from table 1, combine tables if date and ID is equal.

Final table stated as below, the row number is still 3 and 13/08/2022- ID C amount2 100 added same row.

Please can you share in script?

Thanks a lot in advance

Table1:         Table2:      
Date ID Amount1 Amount2   Date ID Amount1 Amount2
12.08.2022 C 1 500   13.08.2022 C   100
13.08.2022 C 2            
14.08.2022 A 3 200          
                 
                 
                 
Final_Required_Table              
Date ID Amount1 Amount2          
12.08.2022 C 1 500          
13.08.2022 C 2 100          
14.08.2022 A 3 200          
Labels (3)
3 Replies
sidhiq91
Specialist II
Specialist II

@EAK  Please see the code below that I have used in the Back end to get the desired output:

NoConcatenate
Temp:
Load Date&','&ID as Key,
Amount1,
emptyisnull(Amount2) as Amount2
inline [
Date, ID, Amount1, Amount2
12.08.2022, C, 1, 500
13.08.2022, C, 2,
14.08.2022, A, 3, 200

];

left join (Temp)

Load
Date&','&ID as Key,
Amount1 as Amount11,
EmptyIsNull(Amount2) as Amount21

Inline [
Date, ID, Amount1, Amount2
13.08.2022, C, ,100
];

 

NoConcatenate
Temp1:
Load Key,
subfield(Key,',',1) as Date,
subfield(Key,',',2) as ID,
Amount1,
Coalesce(Amount2,Amount21) as Amount2

Resident Temp;
Drop field Key;

Drop table Temp;

Exit Script;

If this resolves your issue, please like and accept it as a solution.

sidhiq91_0-1664622904372.png

 

EAK
Contributor
Contributor
Author

thank you

sidhiq91
Specialist II
Specialist II

@EAK Could you please like and accept it as a solution if it has a resolved your issue?