Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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.
Load
Field1,
Mid(Field1,IterNo(),1) as Field2
Inline
[Field1
A
AB
B]
While IterNo() <= Len(Field1);
Load
Field1,
Mid(Field1,IterNo(),1) as Field2
Inline
[Field1
A
AB
B]
While IterNo() <= Len(Field1);
Hi Hic,
Thank you for quick response, it worked
Could you please explain how its mapping internally
This load statement creates a table that looks like:
Each record corresponds to one of the lines in your picture:
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.
Thank you Hic!!