Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Add data from field to another field

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

(qvd);


I hope you understad what I'm looking for and have any suggestion.



5 Replies
sunny_talwar

May be try this:

Employee:

LOAD Emp_Lastname,

    Emp_Firstname,

    Employee_ID,

    Full_Emp_Name,

    Manager_ID,

    TrafficArea,

    Unit

FROM

(qvd);


Join (Employee)

LOAD Emp_Lastname as Manager_Lastname,

          Emp_Firstname as Manager_Firstname,

          Manager_ID as Employee_ID

Resident Employee;

maxgro
MVP
MVP

maybe

MapManager:

Mapping load

    Employee_ID,

    Full_Emp_Name

FROM (qvd);   

Employee:

LOAD

  Emp_Lastname,

    Emp_Firstname,

    Employee_ID,

    Full_Emp_Name,

    Manager_ID,

    TrafficArea,

    Unit,

    ApplyMap('MapManager', Manager_ID) as Full_Mgr_Name

FROM (qvd);

harsh44_bhatia
Creator
Creator

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

(qvd);


left join(Employee)

load

Manager_ID as Employee_ID,

Emp_Firstname & ' ' & Emp_Lastname as ManagerName

resident

Employee;

MK_QSL
MVP
MVP

Employee:

LOAD Emp_Lastname,

    Emp_Firstname,

    Employee_ID,

    Full_Emp_Name,

    Manager_ID,

    TrafficArea,

    Unit

FROM

(qvd);


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;

Peter_Cammaert
Partner - Champion III
Partner - Champion III

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 (qvd);


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