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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
sayadutt
Creator
Creator

Truncating trailing 2 spaces from a field

HI,

i have a list where few values have 2 traling spaces while others don't.

how can I write a generalized code at the time of loading, which will delete the 2 trailing spaces (at end) if applicable else ignore.

Thanks

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Sayantan Dutta wrote:

But the moment I do load from SharePoint, 2 extra spaces are getting added at the end, and they are not getting truncated using Trim.

Then they could be non-breaking spaces (unicode char 0xA0 (160)).

     PurgeChar([Associate Working On], chr(160)) as Test  

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

14 Replies
ashfaq_haseeb
Champion III
Champion III

HI,

use

Trim(field) as Field.

Regards

ASHFAQ

sayadutt
Creator
Creator
Author

Hi Ashfaq,

How the Trim works when the Field consists of more than 1 word?

will

Trim([string1 string2]) as Field

work?

Thanks

ashfaq_haseeb
Champion III
Champion III

Hi,

Can you attach some sample data.

Regards

ASHFAQ

sayadutt
Creator
Creator
Author

Associate Working On

Abdul Sheikh 

Abhay Jagtap

Abhishek Gupta

Abhitanshu Shukla 

Associate Working On : is the field name

And few records have 2 spaces at the end

Thanks

Not applicable

Hi ,

if u are merging two field then ,

Try Like this Trim(Field1)&Trim(Field2) as Field

Thanks Saurabh

tresesco
MVP
MVP

Trim() removes the spaces from both ends and NOT from within the string. So you get your desired result with trim().

Not applicable

Hi , if u have spaces in right try like this Rtrim(Associate Working On) Thanks

ashfaq_haseeb
Champion III
Champion III

Hi,

have a look at attached application.

use below code

load *, trim([Associate Working On]) as Test1,

Replace([Associate Working On],' ','') as Test2;

load * Inline

[

"Associate Working On"

"Abdul Sheikh "

"Abhay Jagtap"

"Abhishek Gupta"

"Abhitanshu Shukla "

];

Regards

ASHFAQ

sayadutt
Creator
Creator
Author

Hi,

Your above sample works fine if we do a Inline Load.

But the moment I do load from SharePoint, 2 extra spaces are getting added at the end, and they are not getting truncated using Trim.

LOAD 

     Trim([Associate Working On]) as Test   

FROM

[sharepoint list path]

(html, utf8, embedded labels, table is @4);

I am exporting Test to excel and can see 2 extra spaces added automatically. My data don't have these spaces.

Thanks