Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor III
Contributor III

Split Text in a field without seperating words

Hello Qlikview-Community,

i am looking for a solution to the following problem:

Ich have a text field = Name in a table with up to 80 chars long.

I want to seperate it into two textfields Name1 and Name2, but without sperating words.

 

Example:

Namefield=This is a text which is much much much longer than 40 chars, but not longer than 80

LEFT(Namefield,40) AS Namefield1 = This is a text which is much much much l

RIGHT(Namefield,40) AS Namefield2 = onger than 40 chars, but not longer than 80

Is there a away to avoid seperating single words dynamically?

 

Labels (1)
1 Solution

Accepted Solutions

Try this

Table:
LOAD *,
	 Index(Left(Namefield, 40), ' ', -1) as SpacePos,
	 Left(Namefield, Index(Left(Namefield, 40), ' ', -1)) as Namefield1,
	 Right(Namefield, Len(Namefield) - Index(Left(Namefield, 40), ' ', -1)) as Namefield2;
LOAD * INLINE [
    Namefield
    "This is a text which is much much much longer than 40 chars, but not longer than 80"
    "This is a text which is much much longer than 40 chars, but not longer than 80"
    "This is a text which is much longer than 40 chars, but not longer than 80"
];

View solution in original post

4 Replies
Highlighted

In this case, where would you want the longer to show up? First Half or Second half and why?? or does it not matter?

Highlighted
Contributor III
Contributor III

The length of Namefield1 should not exceed 40 chars, so the longer should go completly to Namefield2

Try this

Table:
LOAD *,
	 Index(Left(Namefield, 40), ' ', -1) as SpacePos,
	 Left(Namefield, Index(Left(Namefield, 40), ' ', -1)) as Namefield1,
	 Right(Namefield, Len(Namefield) - Index(Left(Namefield, 40), ' ', -1)) as Namefield2;
LOAD * INLINE [
    Namefield
    "This is a text which is much much much longer than 40 chars, but not longer than 80"
    "This is a text which is much much longer than 40 chars, but not longer than 80"
    "This is a text which is much longer than 40 chars, but not longer than 80"
];

View solution in original post

Highlighted
Contributor III
Contributor III

Thank you very much Sunny_talwar,

i just tired it out and it works like a charm!

 

Best wishes,

Hermann