Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
BootCam
Creator
Creator

Get some values in a field and put a single label on those values while keeping all other values as is within the same field

Hi All,

Can we do something like this in the same field in a table?

MyTable:
Load * Inline [
MyField
A
B
C
D
E
F
G
];

NoConcatenate
Load 
If(Match(MyField, 'A','B','C'), 'HH',
If(Match(MyField, 'A'), 'A',
If(Match(MyField, 'B'), 'B',
If(Match(MyField, 'C'), 'C',
If(Match(MyField, 'D'), 'D',
If(Match(MyField, 'E'), 'E',
If(Match(MyField, 'F'), 'F',
If(Match(MyField, 'G'), 'G')))))))) as MyField2
;

Resident MyTable;

Drop Table MyTable;

 

The output table should look like this:

MyField2
A
B
C
D
E
F
G
HH

 

 

Labels (2)
1 Reply
Jebrezov
Contributor III
Contributor III

Would something like this do what you need? I moved the 'HH' as the "ELSE" portion of the last if statement so that if the value in MyField was not found in any defined match statements, it would return the 'HH' value. 

Also, I added X,Y,Z to your inline list to test to verify they all displayed HH in the result. I had to include MyField in the reload in order to show all output rows in the app sheet (otherwise the output of just MyField2 would only have 1 row showing 'HH' because the app shows distinct values in a table.

I'm not 100% sure i'm understanding what you need, but wanted to share this in case it is what you need.

MyTable:
Load * Inline [
MyField
A
B
C
D
E
F
G
X
Y
Z
];

NoConcatenate
Load
MyField,
If(Match(MyField, 'A'), 'A',
If(Match(MyField, 'B'), 'B',
If(Match(MyField, 'C'), 'C',
If(Match(MyField, 'D'), 'D',
If(Match(MyField, 'E'), 'E',
If(Match(MyField, 'F'), 'F',
If(Match(MyField, 'G'), 'G',
'HH'))))))) as MyField2
Resident MyTable;

Drop Table MyTable;

Output here:

Jebrezov_0-1700603720446.png