Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Learn how to migrate to Qlik Cloud Analytics™: On-Demand Briefing!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

I want to split a string into 35 charcters.


Hi,

           It;s urgent.I tried a lot but i didnt get it:

a string has many charcters :

1st 35 charcters into one field but should complete a word  .

ex:  the premium life insurance corporate company   which has a filed name  NM

it comes:

left(NM,35)

result:

the premium life insurance corporat           into NM1

e company                                                   into NM2

but  i want

the premium life insurance                             into NM1

corporate company                                          into  NM2

pls help.Thanks in advance

1 Solution

Accepted Solutions
sunny_talwar

Can you try this:

Tried this?

Table:

LOAD *,

  Left(Field, 35) as OldNM,

  Trim(If(Len(Field) <= 35, Field, Left(Field, (Index(Left(Field, 36), ' ', -1))))) as NM1,

  Trim(If(Len(Field) <= 35, '', Right(Field, (Len(Field) - (Index(Left(Field, 35), ' ', -1)))))) as NM2 ;

LOAD * Inline [

Field

the premium life insurance corporate company

];

View solution in original post

24 Replies
Qrishna
Master
Master

Hi uma,

use  mid function instead of left. i.e  mid(NM,27).

1.PNG

see attached for the script.

Thanks

Krishna

sunny_talwar

Try this script:

Table:

LOAD *,

  Left(Field, (Index(Left(Field, 35), ' ', -1))) as NM1,

  Right(Field, (Len(Field) - (Index(Left(Field, 35), ' ', -1)))) as NM2 ;

LOAD * Inline [

Field

the premium life insurance corporate company

];

Output

Capture.PNG

Not applicable
Author

sunindia  ur script  not working  excatly how i want

krishna  can u write script in here  i cant open .qvw file outside  (restricted in office)

anybody  script here pls

Qrishna
Master
Master

tab_tmp:

  load * inline [

  NM

  the premium life insurance corporate company

  ];

   

tab:

LOAD

NM ,

mid(NM,27) as [NM 1]

resident  tab_tmp;

drop table tab_tmp;

sunny_talwar

Try this:

Table:

LOAD *,

  Left(Field, 35) as OldNM,

  If(Len(Field) <= 35, Field, Left(Field, (Index(Left(Field, 36), ' ', -1)))) as NM1,

   If(Len(Field) <= 35, '', Right(Field, (Len(Field) - (Index(Left(Field, 35), ' ', -1))))) as NM2 ;

LOAD * Inline [

Field

the premium life insurance corporate company

];

Not applicable
Author

this NM is a field name which has 7,000 columns  with different   number of chacters.not specific to this.

the premium life insurance corporate company  is just example.

Qrishna
Master
Master

post the qvw with just some sample data and the common requirement on that column.

Not applicable
Author

is there any way we can write it in expression  in straight table

as i said  i have a table with 7,000 records  in that i am pulling  NM field and dividing it into NM1,NM2

by using (set analysis)  expression.

PLs help

sunny_talwar

Did you try the new script?

Table:

LOAD *,

  Left(Field, 35) as OldNM,

  If(Len(Field) <= 35, Field, Left(Field, (Index(Left(Field, 36), ' ', -1)))) as NM1,

   If(Len(Field) <= 35, '', Right(Field, (Len(Field) - (Index(Left(Field, 35), ' ', -1))))) as NM2 ;

LOAD * Inline [

Field

the premium life insurance corporate company

];

If it works on the back end, you should be able to use the same in the straight table as expressions also.

HTH

Best,

Sunny