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: 
farolito20
Contributor III
Contributor III

Replace data

How can I replace data?

I have two tables, and I wanna replace a name:

Table1:

ID,Name,Age

1,Luis,15

Table2:

ID,Name,Age

1,Marina,15

I need put the value for name in the first table, in the second, if the combination of ID,Age is the same

Table2:

ID,Name,Age

1,Luis,15

1 Solution

Accepted Solutions
swuehl
MVP
MVP

You can use a mapping table to replace the names in table 2 with the names of table 1, something along these lines:

Table1:

LOAD * INLINE [

ID,Name,Age

1,Luis,15

];

NAMEMAP:

MAPPING LOAD

              ID&'-'&Age as Key,

              Name

Resident Table1;

Table2:

LOAD ID,

           applymap('NAMEMAP', ID&'-'&Age, Name) as Name,

           Age

INLINE [

ID,Name,Age

1,Marina,15

1,Marina,16

];

View solution in original post

5 Replies
swuehl
MVP
MVP

You can use a mapping table to replace the names in table 2 with the names of table 1, something along these lines:

Table1:

LOAD * INLINE [

ID,Name,Age

1,Luis,15

];

NAMEMAP:

MAPPING LOAD

              ID&'-'&Age as Key,

              Name

Resident Table1;

Table2:

LOAD ID,

           applymap('NAMEMAP', ID&'-'&Age, Name) as Name,

           Age

INLINE [

ID,Name,Age

1,Marina,15

1,Marina,16

];

farolito20
Contributor III
Contributor III
Author

What's ID&'-'&Age?

farolito20
Contributor III
Contributor III
Author

Thanks

swuehl
MVP
MVP

& id the string concatenation operator in QV, so ID&'-'&Age is creating a new string by concatenating field ID and field Age with an additional '-' in the middle (as separator).

As I understood, you'll need to check for same ID and age, then replace the name by the name found in table 1, correct?

farolito20
Contributor III
Contributor III
Author

Yes