Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
hbuchetmann
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
sunny_talwar

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
sunny_talwar

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

hbuchetmann
Contributor III
Contributor III
Author

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

sunny_talwar

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"
];
hbuchetmann
Contributor III
Contributor III
Author

Thank you very much Sunny_talwar,

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

 

Best wishes,

Hermann