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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Single table join on different column names

I have a single table with the following fields:

UserNoUserNameCreatedbyUserNo
1

John Smith

2
2William Jones
3Sally Adams2
4George Doe3
5Lynda Peters3

I would like to look up the name of who created each of the users.  What would the load script statements look like?

UserNoUserNameCreatedbyName
1

John Smith

William Jones
2William Jones
3Sally AdamsWilliam Jones
4George DoeSally Adams
5Lynda PetersSally Adams
6 Replies
Nicole-Smith

User:

LOAD

UserNo,

UserName,

CreatedbyUserNo

FROM YourDataSource;

LEFT JOIN (User)

LOAD

UserNo,

UserName,

CreatedbyName

FROM YourDataSource2;

Anonymous
Not applicable
Author

The load should be from one single data source.  The illustration shows the input table as table 1 and the desired output as table 2.

MayilVahanan

HI

Try like this

Table1:

LOAD

UserNo & '_'& UserName As Key,

UserNo,

UserName,

CreatedbyUserNo

FROM table1;

Edit:

Map1:

Mapping

Load UserNo, UserName AS CreatedbyUserNo

Resident Table1;

Load

     Key, UserNo, UserName, ApplyMap('Map1', CreatedbyUserNo) As CreatedbyName

Resident Table1;

Drop table Table1;

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Nicole-Smith

User:

LOAD

UserNo,

UserName,

CreatedbyUserNo

FROM YourDataSource;

LEFT JOIN (User)

LOAD

UserNo as CreatedbyUserNo,

UserName as CreatedbyName

RESIDENT User;

Anonymous
Not applicable
Author

Hi

I am a fan of applymap() that Mayil Vahanan Ramasamy mentioned,  so you could try this:

MyData:

LOAD * INLINE [

    UsewrNo, UserName, CreatebyUserNo

    1, John Smith, 2

    2, William Jones

    3, Sally Adams, 2

    4, George Doe, 3

    5, Lynda Peters, 3

];

MyMap:

Mapping load

CreatebyUserNo ,

UserName

resident MyData

;

RevisedTable:

load

UsewrNo ,

UserName ,

applymap ( 'MyMap' , CreatebyUserNo ) as CreatedByName

resident MyData

drop table MyData ;






Best Regards,     Bill

Not applicable
Author

Hi Jerry,  Try with this code.

Script.PNG.png

Result:

Table.PNG.png

Regards