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

Combine three fields into one field

Hello, 

I have a table with Cost_Area  field which has values as:


1.PNG

 

 

 

 

 

 

 

 

 

 

 

I am trying to combine multiple fields ('CONT HDWR', 'CONT RESALE', 'CONTROLS ENG') in load script as one field  (named "Controls Eng"). So, my resultant column "Controls Eng" would be a list having values like 'CONT HDWR', 'CONT RESALE', 'CONTROLS ENG' and not the other fields.  

How can I do this? 

attach is the file for reference

Labels (2)
1 Solution

Accepted Solutions
rubenmarin

It can be done with a nested if:

If(Match([Cost Area], 'CONT HDWR', 'CONT RESALE', 'CONTROLS ENG'), 'Controls Eng',
If(Match([Cost Area], 'MECH HDWR', 'MECH INSTALL', 'MECH RESALE'), 'Mechanical Eng')
) as [Area]

 

Using variables:

 

SET vControlsEng = 'CONT HDWR', 'CONT RESALE', 'CONTROLS ENG';
SET vMechanicalEng = 'MECH HDWR', 'MECH INSTALL', 'MECH RESALE';

LOAD ...
If(Match([Cost Area], $(vControlsEng)), 'Controls Eng',
  If(Match([Cost Area], $(vMechanicalEng)), 'Mechanical Eng'
) ) as [Area]
...



Or using applymap (recommended):

mapArea:
LOAD * inline [
CostArea, Area
CONT HDWR, Controls Eng
CONT RESALE, Controls Eng
CONTROLS ENG, Controls Eng
MECH HDWR, Mechanical Eng
ECH INSTALL, Mechanical Eng
MECH RESALE, Mechanical Eng
];

LOAD ...
Applymap('mapArea', [Cost Area], null()) as Area
...

View solution in original post

4 Replies
rubenmarin

Hi, for only that 3 values maybe just an If:
If(Match([Cost Area], 'CONT HDWR', 'CONT RESALE', 'CONTROLS ENG'), [Cost Area]) as [Controls Eng]
bhaveshp90
Creator III
Creator III
Author

@rubenmarin  I tried the Match() but my goal is to create a separate column "Area"


1.PNG

 

 

where Controls Eng = 'CONT HDWR', 'CONT RESALE', 'CONTROLS ENG' values 

Mechanical Eng = 'MECH HDWR', 'MECH INSTALL', 'MECH RESALE' values 

passionate
Specialist
Specialist

Use Appymap by creating a mapping table of whatever you require and create a separate column in data model for this.

rubenmarin

It can be done with a nested if:

If(Match([Cost Area], 'CONT HDWR', 'CONT RESALE', 'CONTROLS ENG'), 'Controls Eng',
If(Match([Cost Area], 'MECH HDWR', 'MECH INSTALL', 'MECH RESALE'), 'Mechanical Eng')
) as [Area]

 

Using variables:

 

SET vControlsEng = 'CONT HDWR', 'CONT RESALE', 'CONTROLS ENG';
SET vMechanicalEng = 'MECH HDWR', 'MECH INSTALL', 'MECH RESALE';

LOAD ...
If(Match([Cost Area], $(vControlsEng)), 'Controls Eng',
  If(Match([Cost Area], $(vMechanicalEng)), 'Mechanical Eng'
) ) as [Area]
...



Or using applymap (recommended):

mapArea:
LOAD * inline [
CostArea, Area
CONT HDWR, Controls Eng
CONT RESALE, Controls Eng
CONTROLS ENG, Controls Eng
MECH HDWR, Mechanical Eng
ECH INSTALL, Mechanical Eng
MECH RESALE, Mechanical Eng
];

LOAD ...
Applymap('mapArea', [Cost Area], null()) as Area
...