Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Qlikview script function to remove leading spaces at the end

Hi,

I want to know to how to remove the spaces at the end of the string.

Eg: the qlikview is a learning tool. 

Qlikview is analytics tool.          

The length of the string varies and the spaces of the string varies to each string.. For eg.. The string 1 contains 5 leading spaces at the end..

The 2nd string contains 10 leading spaces at the end..I can't use replace function for removing because it will remove all the spaces including the spaces in between the string...

Can u please provide solution for the issue..

Message was edited by: vinu priya

1 Solution

Accepted Solutions

Re: Qlikview script function to remove leading spaces at the end

I think there are some white spaces in your excel file cells.

Just copy one of the cell value from excel in notepad, copy that value from notepad and replace it in QlikView with Blank value.

Works for me. See the below. Also

Data:
LOAD KeepChar([  Material],'0123456789') as Material,
rtrim(replace([Material Desc                          ],' ',' ')) as Material_Description
FROM
[test1(1).xlsx]
(
ooxml, embedded labels, table is Sheet1);

In above replace function first blank space is copied from notepad which we are replacing with blank

30 Replies
sinanozdemir
Valued Contributor III

Re: Qlikview script function to remove leading spaces at the end

Can you try Trim() function?

Trim(Your_Column_Name) this should remove the spaces.

martinpohl
Valued Contributor II

Re: Qlikview script function to remove leading spaces at the end

you can use ltrim and rtrim to trim spaces at the beginning and the end

ltrim(rtrim(yourfield)) as yourfield

trim will also delete spaces between text

Regards

Re: Qlikview script function to remove leading spaces at the end

Hi,


to only trim trailing spaces, you can use RTrim() :

RTrim ‒ QlikView

LTrim() only trims leading spaces

LTrim ‒ QlikView

and Trim() both leading and trailing spaces.

Trim ‒ QlikView

hope this helps

regards

Marco

Re: Qlikview script function to remove leading spaces at the end

RTrim(Your_field_name) // this will remove the spaces at the end

LTrim(Your_field_name) // this will remove the spaces at the start of your statement


Trim(Your_field_name) // this will remove the spaces in both the ends i.e. at the start and at the end of your statements

Not applicable

Re: Qlikview script function to remove leading spaces at the end

Hi All,

Thanks for your replies.

I have written function like

trim(Material) & ' ' & rtrim(Material_description) as Material_and_Description,

Because I'm having spaces at both the ends for Material and spaces at the end for material description column.

For material it is working and rtrim for Material description is not working.

Can you please suggest

Not applicable

Re: Qlikview script function to remove leading spaces at the end

Trim(Your_field_name)

Not applicable

Re: Qlikview script function to remove leading spaces at the end

Rtrim(material_description) is not removing the spaces at the end

sureshqv
Esteemed Contributor III

Re: Qlikview script function to remove leading spaces at the end

did u concatenated those fields?

if yes

trim(Material) & '_ ' & rtrim(Material_description) as Material_and_Description,

Not applicable

Re: Qlikview script function to remove leading spaces at the end

I used this function but the spaces at the end of the material description is still not removed.

Community Browser