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: 
Vasu2
Contributor II
Contributor II

Row Data in Column

I need to combine 2 Tables Data.

Table1:

LOAD * inline [

Material| Type

M1|abcd

] (delimiter is '|');

 

Table2:

LOAD * inline [

Material|Unit|Unit2

M1|EA|IN_EA

M1|IP|IN_IP

M1|MP|IN_MP

] (delimiter is '|');

 

Output is coming as below:

Vasu2_0-1675406928857.png

 

Expected output is:

Material

IP UOM

MP UOM

EA UOM

M1

IN_IP

IN_MP

IN_EA

 

IP_UOM  =if(Unit='IP’,Unit2)

EA_UOM =if(Unit='EA',Unit2)

MP_UOM =if(Unit='MP',Unit2)

 

I tried all the joins(Left, Right and Inner) but none of them is working.

Any suggestions?

 

Labels (1)
1 Solution

Accepted Solutions
sidhiq91
Specialist II
Specialist II

@Vasu2 Please see the code below:

NoConcatenate
Table1:
LOAD * inline [

Material| Type

M1|abcd

] (delimiter is '|');


left join (Table1)
Table2:

LOAD Unit2 as [EA UOM]

inline [

Material|Unit|Unit2

M1|EA|IN_EA

M1|IP|IN_IP

M1|MP|IN_MP

] (delimiter is '|')

where Unit='EA';

left join (Table1)
Table3:

LOAD Unit2 as [IP UOM]

inline [

Material|Unit|Unit2

M1|EA|IN_EA

M1|IP|IN_IP

M1|MP|IN_MP

] (delimiter is '|')

where Unit='IP';

left join (Table1)
Table3:

LOAD Unit2 as [MP UOM]

inline [

Material|Unit|Unit2

M1|EA|IN_EA

M1|IP|IN_IP

M1|MP|IN_MP

] (delimiter is '|')

where Unit='MP';

Drop field Type from Table1;

Exit Script;

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

sidhiq91_0-1675423126955.png

 

View solution in original post

2 Replies
jbhappysocks
Creator II
Creator II

Hi

A little bit depending on how much you simplified your data you can use the generic load. I added Type as a part of the connection here just to show how it works with more than just Material as Key.

 

Table1:

LOAD * inline [

Material| Type

M1|abcd
M1|efgh
] (delimiter is '|');


Table2:
Generic
load
Material,
Type,
Unit&'_UOM' as Attribute,
Unit2 as Value;

LOAD * inline [

Material|Type|Unit|Unit2

M1|abcd|EA|IN_EA

M1|abcd|IP|IN_IP

M1|abcd|MP|IN_MP

M1|efgh|EA|IN_EA2

M1|efgh|IP|IN_IP2

M1|efgh|MP|IN_MP2

] (delimiter is '|');


for each Unit in 'EA','IP','MP';
left join (Table1)
load * Resident Table2.$(Unit)_UOM;

drop Table Table2.$(Unit)_UOM;
next Unit;

 

jbhappysocks_0-1675413881861.png

 

 

sidhiq91
Specialist II
Specialist II

@Vasu2 Please see the code below:

NoConcatenate
Table1:
LOAD * inline [

Material| Type

M1|abcd

] (delimiter is '|');


left join (Table1)
Table2:

LOAD Unit2 as [EA UOM]

inline [

Material|Unit|Unit2

M1|EA|IN_EA

M1|IP|IN_IP

M1|MP|IN_MP

] (delimiter is '|')

where Unit='EA';

left join (Table1)
Table3:

LOAD Unit2 as [IP UOM]

inline [

Material|Unit|Unit2

M1|EA|IN_EA

M1|IP|IN_IP

M1|MP|IN_MP

] (delimiter is '|')

where Unit='IP';

left join (Table1)
Table3:

LOAD Unit2 as [MP UOM]

inline [

Material|Unit|Unit2

M1|EA|IN_EA

M1|IP|IN_IP

M1|MP|IN_MP

] (delimiter is '|')

where Unit='MP';

Drop field Type from Table1;

Exit Script;

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

sidhiq91_0-1675423126955.png