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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
racer25
Creator
Creator

Mapping Load Challenge

Hi 

I have a user table and within that user table there is always a supervisor. That supervisor is also a user and equally has a supervisor until you get to the boss. 

 

I thought this should be a simple load and either a mapping load or left join but I am yet to get the right answer and reviewing the data that is not the issue.

I have put below a BEFORE and OUTCOME table.

USR_USERIDUSR_NAMEUSR_SUPERVISOR  
ABC123WorkerABC456  
ABC456ManagerABC999  
ABC999Senior ManagerABC999  
     
OUTCOME    
     
USR_USERIDUSR_NAMEMANAGER 1MANAGER 2 
ABC123WorkerManagerSenior Manager 
ABC456ManagerSenior ManagerSenior Manager 
ABC456Senior ManagerSenior ManagerSenior Manager 

 

I did start with 

TEMP:
LOAD USR_USERID,
USR_NAME,
USR_SUPERVISOR as Manager1
FROM
[C:\Qlikview\In Development\USER TABLE.xlsx](ooxml, embedded labels, table is Sheet1);

\\ Load Table

LOAD
USR_SUPERVISOR as USR_USERID,
USR_SUPERVISOR as Manager2
FROM
[C:\Qlikview\In Development\USER TABLE.xlsx]
(ooxml, embedded labels, table is Sheet1);

\\ Get next Manager

I am clearly doing something quite basic incorrect but can't see what.

Any help would be appreciated.

Thanks,

Rob

 

 

 

 

Labels (1)
1 Solution

Accepted Solutions
chrismarlow
Specialist II
Specialist II

Hi,

You need to add the supervisors ID when you join to iterate up - then join to that, something like;

data:
LOAD * INLINE [
USR_USERID, USR_NAME, USR_SUPERVISOR
ABC123, Worker, ABC456
ABC456, Manager, ABC999
ABC999, Senior Manager, ABC999
];

left join (data)
load
	USR_USERID AS USR_SUPERVISOR, 
	USR_NAME AS Manager1, 
	USR_SUPERVISOR AS USR_SUPERVISOR2
resident data;

left join (data)
load
	USR_USERID AS USR_SUPERVISOR2, 
	USR_NAME AS Manager2
resident data;

drop fields USR_SUPERVISOR2;

Cheers,

Chris.

View solution in original post

2 Replies
chrismarlow
Specialist II
Specialist II

Hi,

You need to add the supervisors ID when you join to iterate up - then join to that, something like;

data:
LOAD * INLINE [
USR_USERID, USR_NAME, USR_SUPERVISOR
ABC123, Worker, ABC456
ABC456, Manager, ABC999
ABC999, Senior Manager, ABC999
];

left join (data)
load
	USR_USERID AS USR_SUPERVISOR, 
	USR_NAME AS Manager1, 
	USR_SUPERVISOR AS USR_SUPERVISOR2
resident data;

left join (data)
load
	USR_USERID AS USR_SUPERVISOR2, 
	USR_NAME AS Manager2
resident data;

drop fields USR_SUPERVISOR2;

Cheers,

Chris.

racer25
Creator
Creator
Author

Thanks Chris worked a treat on the real data.