Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
IMPORTANT security patches for GeoAnalytics Server available to download: READ DETAILS
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.