Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Qlik Experts,
I have a string field which I want to display in a report. The problem: the string isn't preformatted and look something like below-
Actual output:
-Lorem Ipsum is simply dummy text of the printing and typesetting industry. -Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. -It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. -It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
Q. How do I break the string and add a line new line after every occurance of '-' ?
Desired output:
-Lorem Ipsum is simply dummy text of the printing and typesetting industry.
-Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
-It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
-It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
Hi,
Use subfield(),
try like
Load
subfield(fieldname,'-') as fieldName
from tableName;
Regards,
hi,
you can try subfield function
subfield(YourFieldname(messagefield), '-', 1) as FirstSentense,
subfield(YourFieldname(messagefield), '-', 2) as SecondSentense,
subfield(YourFieldname(messagefield), '-', 3) as ThirdSentense,
subfield(YourFieldname(messagefield), '-', 4) as ForthSentense,
subfield(YourFieldname(messagefield), '-', 5) as FifthSentense,
subfield(YourFieldname(messagefield), '-', 6) as SixthSentense,
and DO cross table function, you will get all Sentences will come under sequence as your expected result,
ksrini
Hi @Omkar13 , you can try this, in script or in a expression :
expression :
replace(YourField, '-', chr(13))
script :
replace(YourField, '-', chr(13)) as Text
Hi,
Use subfield(),
try like
Load
subfield(fieldname,'-') as fieldName
from tableName;
Regards,
hi,
you can try subfield function
subfield(YourFieldname(messagefield), '-', 1) as FirstSentense,
subfield(YourFieldname(messagefield), '-', 2) as SecondSentense,
subfield(YourFieldname(messagefield), '-', 3) as ThirdSentense,
subfield(YourFieldname(messagefield), '-', 4) as ForthSentense,
subfield(YourFieldname(messagefield), '-', 5) as FifthSentense,
subfield(YourFieldname(messagefield), '-', 6) as SixthSentense,
and DO cross table function, you will get all Sentences will come under sequence as your expected result,
ksrini
Thanks @PrashantSangle @Ksrinivasan I m a complete beginner at QLik Sense. Can you tell me how to apply the subfield and where? or Point me to correct direction. I will explore how to apply subfield on the internet
can you share sample data with expected output. Your requirement is not giving full idea about your issue
subfield() work in both script as well as in front end level.
Regards,
Try this,
tab1:
LOAD '-'&SubField(Str,'-') As Line;
LOAD * INLINE [
Str
"-Lorem Ipsum is simply dummy text of the printing and typesetting industry. -Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. -It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. -It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
];
Output:
Hi @Omkar13 , you can try this, in script or in a expression :
expression :
replace(YourField, '-', chr(13))
script :
replace(YourField, '-', chr(13)) as Text
Thanks @QFabian that did the trick.😁 I believe using subfield is also a great option when it comes to breaking down large string value but in my case replace(YourField, '-', chr(13)) is a more appropriate solution as I want to show the value in a single text field.
Thanks @PrashantSangle @Ksrinivasan your recommended solution also applies on my query and provides me more ways to manipulate larger string values.
Excelent @Omkar13 , but You have to consider that subfield with 2 parameters is going to create more rows, so that can change results in possible counts formulas.