Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
paulwalker
Creator III
Creator III

Need Help

Hi Community,

I have one requirement..

I have 2 tables

Table1:

ID, Value

100, 2500

200, 3000

300, 3500

Table2:

ID,  Value

100, 1000

200,  5000

300,  2500,

400,  4500

500,  2000

Here, ID values 100, 200, 300 are same but values are different..

I want to replace the Values in Table2.

My Output should be

Output:

ID, Value

100, 2500

200,  3000

300,  3500,

400,  4500

500,  2000

Thanks in Advance...

16 Replies
Ralf-Narfeldt
Employee
Employee

Table1:

Load * Inline [

ID, Value

100, 2500

200, 3000

300, 3500];

Load * Inline [

ID,  Value

100, 1000

200,  5000

300,  2500,

400,  4500

500,  2000] Where Not Exists(ID) ;

Anonymous
Not applicable

try this:

Table1:

load ID, Value

from ...

Table2:

noconcatenate load ID, Value

from  ...

where not exists (ID)

left join(Table2)

load *

resident Table1

drop Table1;

now your table 2 holds your desired values, maybe you want to sort your table

sorrakis01
Specialist
Specialist

Table1:

LOAD * INLINE [

ID, Value

100, 2500

200, 3000

300, 3500

];

JOIN (if you like is not necesary)

Table2:

LOAD * INLINE [

ID,  Value

100, 1000

200,  5000

300,  2500,

400,  4500

500,  2000

]

where not exists(ID);

pokassov
Specialist
Specialist

Hello!

MapTab:

Mapping

load

ID, Value

resident Table1;


Table2:

Load

ID,

ApplyMap('MapTab',ID,Value)          As Value

from ...;

maxgro
MVP
MVP

another one, using applymap with 3 parameters, could be

Table1:

mapping load * inline [

ID, Value

100, 2500

200, 3000

300, 3500

];

Table2:

load

  ID,

  ApplyMap('Table1', ID, Value) as Value

inline [

ID,  Value

100, 1000

200,  5000

300,  2500,

400,  4500

500,  2000

];

1.png

sasiparupudi1
Master III
Master III

Table1:

mapping LOAD * Inline

[

ID, Value

100, 2500

200, 3000

300, 3500

];

NoConcatenate

Table2:

load

ID,ApplyMap('Table1',ID,Value) as Value

inline

[

ID,  Value

100, 1000

200,  5000

300,  2500

400,  4500

500,  2000

];

paulwalker
Creator III
Creator III
Author

If i have duplicate ID's,

Is this work ApplyMap perfectly???

maxgro
MVP
MVP

do you mean like this (duplicated in mapping table)? 100 is duplicated

Table1:

load * inline [

ID, Value

100, 2500

200, 3000

300, 3500

100, 999999999

];

mapping load * Resident Table1 order by Value desc;

DROP Table Table1;

Table2:

load

  ID,

  ApplyMap('Table1', ID, Value) as Value

inline [

ID,  Value

100, 1000

200,  5000

300,  2500,

400,  4500

500,  2000

];

I think the applymap uses the first one, in that case 9999..... because of the sort in resident load

1.png

and this without sort

1.png

sebastianlettner
Partner - Creator
Partner - Creator

Hi,

here is an example without Mapping

TableA:

LOAD * INLINE

[

    ID, Value

    100, 2500

    200, 3000

    300, 3500

];

TableB:

NoConcatenate

LOAD * INLINE

[

    ID, Value

    100, 1000

    200, 5000

    300, 3500

    400, 4500

    500, 2000

];

Outer Join(TableB)

LOAD

    ID,

    Value as ValueA

Resident TableA;

Output:

NoConcatenate

LOAD

    ID,

    if(not IsNull(ValueA), ValueA, Value) as Value

Resident TableB;

drop tables TableA, TableB;