Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
apthansh
Creator
Creator

String manipilation

Code looks like below ....

001-0525-04-555-121 

001-0525-02-555-121

001-0525-01-555-121

001-0525-04-555-122

001-0525-02-555-122

001-0525-01-555-122

I have code as above in the file..If anything has 04 then ABC,IF 02 THE DEF ,IF 01 then HIJ


How can I do thia ?


Thank you.

1 Solution

Accepted Solutions
vishsaggi
Champion III
Champion III

Try this may be:

LOAD *,

     Pick(Match(Subfield(Value, '-', 3), 04,02,01), 'ABC','DEF','HIJ') AS NewField INLINE [

Value

001-0525-04-555-121

001-0525-02-555-121

001-0525-01-555-121

001-0525-04-555-122

001-0525-02-555-122

001-0525-01-555-122

];

View solution in original post

7 Replies
vishsaggi
Champion III
Champion III

Try this may be:

LOAD *,

     Pick(Match(Subfield(Value, '-', 3), 04,02,01), 'ABC','DEF','HIJ') AS NewField INLINE [

Value

001-0525-04-555-121

001-0525-02-555-121

001-0525-01-555-121

001-0525-04-555-122

001-0525-02-555-122

001-0525-01-555-122

];

apthansh
Creator
Creator
Author

Awesome.Thank you.

apthansh
Creator
Creator
Author

jontydkpi

stalwar1

sunny

I need to add one more to this ...

if 04-555 and 01-555 then XYZ .

Can I add this in the same line of script ?

     Pick(Match(Subfield(Value, '-', 3), 04,02,01), 'ABC','DEF','HIJ') AS NewField

Thank you much.

LOAD *,

     Pick(Match(Subfield(Value, '-', 3), 04,02,01), 'ABC','DEF','HIJ') AS NewField

INLINE [

Value

001-0525-04-555-121

001-0525-02-555-121

001-0525-01-555-121

001-0525-04-555-122

001-0525-02-555-122

001-0525-01-555-122

];

vishsaggi
Champion III
Champion III

In the Same Field you mean ?

apthansh
Creator
Creator
Author

Ya..

trdandamudi
Master II
Master II

May be as below:

LOAD *,
 
If(mid(Value,10,6)='04-555' or mid(Value,10,6)='01-555','XYZ', Pick(Match(Subfield(Value, '-', 3), 04,02,01), 'ABC','DEF','HIJ')) AS NewField
 
INLINE [
  Value
  001-0525-04-555-121
  001-0525-02-555-121
  001-0525-01-555-121
  001-0525-04-555-122
  001-0525-02-555-122
  001-0525-01-555-122
  ]
;

Note: I modified Nagaraju code and added a If condition.

apthansh
Creator
Creator
Author

Awesome. Thank you  very much.