Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Gopi_E
Creator II
Creator II

How to use single value into multiple map conditions in qlik to create new filed.

Hi Qlikers,

How can we map one field value into multiple conditions in same expression to create new filed ?

I have data like Field 1, and required out put is Field 2.

Gopi_E_0-1671522613640.png

Currently the issue is, 'AB' value mapping either one of the Field 2 value. but it should be part of A and B

My expression is : If(Field1='A' OR Field1='AB' , 'A' , If(Field1 = 'B' OR Field1 = 'AB' , 'B')) As Field 2

Can anybody know how can we map 'AB' value into both A and B while creating new Field. 

Thanks in advance.

1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

Load
Field1,
Mid(Field1,IterNo(),1) as Field2
Inline
[Field1
A
AB
B]
While IterNo() <= Len(Field1);

View solution in original post

4 Replies
hic
Former Employee
Former Employee

Load
Field1,
Mid(Field1,IterNo(),1) as Field2
Inline
[Field1
A
AB
B]
While IterNo() <= Len(Field1);

Gopi_E
Creator II
Creator II
Author

Hi Hic,

Thank you for quick response, it worked

Could you please explain how its mapping internally

hic
Former Employee
Former Employee

This load statement creates a table that looks like:

hic_0-1671542609087.png

Each record corresponds to one of the lines in your picture:

hic_1-1671542834412.png

 

The While clause makes the script engine stop and read the input record several times. How many times depends on the clause that follows the "While": IterNo() <= Len(Field1). IterNo() is the counter of this loop.

So the first and last records are read once, and the second record twice. And the Mid() function picks out the correct letter.

Gopi_E
Creator II
Creator II
Author

Thank you Hic!!