Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a table like below that I would like to create a new field with manager names. The ID for every manager is in field Manager_ID and all employess names is in the filed Full_Emp_Name. All employess ID is in field Employee_ID, also the managers.
Employee:
LOAD Emp_Lastname,
Emp_Firstname,
Employee_ID,
Full_Emp_Name,
Manager_ID,
TrafficArea,
Unit
FROM
I hope you understad what I'm looking for and have any suggestion.
May be try this:
Employee:
LOAD Emp_Lastname,
Emp_Firstname,
Employee_ID,
Full_Emp_Name,
Manager_ID,
TrafficArea,
Unit
FROM
Join (Employee)
LOAD Emp_Lastname as Manager_Lastname,
Emp_Firstname as Manager_Firstname,
Manager_ID as Employee_ID
Resident Employee;
maybe
MapManager:
Mapping load
Employee_ID,
Full_Emp_Name
FROM
Employee:
LOAD
Emp_Lastname,
Emp_Firstname,
Employee_ID,
Full_Emp_Name,
Manager_ID,
TrafficArea,
Unit,
ApplyMap('MapManager', Manager_ID) as Full_Mgr_Name
FROM
You need to do a self join with the employee logical table. We do this when we have to derive fields from within the same table.
do something as follows:
Employee:
LOAD Emp_Lastname,
Emp_Firstname,
Employee_ID,
Full_Emp_Name,
Manager_ID,
TrafficArea,
Unit
FROM
left join(Employee)
load
Manager_ID as Employee_ID,
Emp_Firstname & ' ' & Emp_Lastname as ManagerName
resident
Employee;
Employee:
LOAD Emp_Lastname,
Emp_Firstname,
Employee_ID,
Full_Emp_Name,
Manager_ID,
TrafficArea,
Unit
FROM
temp:
Load Distinct Manager_ID Resident Data;
Left Join (temp) Load Employee_ID as Manager_ID, Full_Emp_Name as Manager_Name Resident Data;
Left Join (Data) Load * Resident temp;
Drop Table temp;
IMHO Employee tables usually already are distinct. If so, this simple version will do the same job:
Employee:
LOAD Emp_Lastname,
Emp_Firstname,
Employee_ID,
Full_Emp_Name,
Manager_ID,
TrafficArea,
Unit
FROM
LEFT JOIN (Employee)
LOAD Employee_ID AS Manager_ID, // JOIN on Manager ID, not Employee ID !!!
Full_Emp_Name AS Manager_Full_Name
RESIDENT Employee;
Best,
Peter