Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Merge fields

Greetings,

I've a table setup like this :

IDDefinitionName
1First NameAlexander
2Last NameWise
3First NameChris
4Last NameDamico
5First NameFrederick
6Last NameLeviathan

And i'm wondering if there is a way to merge them to have a table like this:

IDName
1Alexander Wise
3Chris Damico
5Frederick Leviathan

And will i have to create a new table for this ? or is it possible to change the first one ?

Thanks for answer/tips

12 Replies
undergrinder
Specialist II
Specialist II

I see, so you have a key to match

then follow this logic:

table_tmp:

load

     registrary_number,

     Name as First

from [table]

where Definition='First name';

left join(table_tmp)

Load

     registrary_number,

     Name as Last

from

where Definition='Last name';

Table_final:

Load

     registrary_number,

    First&' '&Last as Name

Resident table_tmp;

drop table table_tmp;

G.

gerry_hdm
Creator II
Creator II

here a script is not First and last Name

greetings Gerry

ReadTable:
load * inline [
ID, Definition,Name
1, FirstName, Alexander
2, LastName, Wise
3, FirstName, Chris
4, LastName, Damico
5, FirstName, Frederick
6, LastName, Leviathan
7, LastName, NewName
8, LastName, NewName2
]
;

EndTable:
load *
where not FirstLastName = 'Del'
;
load 
if (Definition  = 'LastName' and Previous(Definition) = 'FirstName' , previous(Name)&', '&Name,
     if (Definition  = 'LastName' and Previous(Definition) = 'LastName', 'noFirstname'&', '&Name , 'Del')) as FirstLastName ,

if (Definition  = 'LastName' and Previous(Definition) = 'FirstName' , previous(ID),
      if (Definition  = 'LastName' and Previous(Definition) = 'LastName', ID , 'Del')) as ID_NEW

resident ReadTable;


drop Table ReadTable;

undergrinder
Specialist II
Specialist II

Hi Gerold,

It is okay, but VIncent post an extra information since,

So the matching pair would always have the same Registrary number

there can be the case the rownumbers are not consecutives, but the registrary number is the key for match.

G.