Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

apthansh
Contributor

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
Esteemed Contributor III

Re: String manipilation

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
Esteemed Contributor III

Re: String manipilation

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

apthansh
Contributor

Re: String manipilation

Awesome.Thank you.

apthansh
Contributor

Re: String manipilation

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
Esteemed Contributor III

Re: String manipilation

In the Same Field you mean ?

apthansh
Contributor

Re: String manipilation

Ya..

trdandamudi
Honored Contributor II

Re: String manipilation

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.

Highlighted
apthansh
Contributor

Re: String manipilation

Awesome. Thank you  very much.