Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
bfournet
New Contributor II

Count leading spaces in a string

Hello! Sorry in advance for my english.

Here is my question: I would like to import data from an Excel file containing one column ("Siege") with leading spaces records.

But while loading data into qlikview, leading spaces are automatically suppressed even using Text() function:

...

Text(Siege) as Siege,

...

The workaround I found is to modify the "Verbatim" variable before loading data and it works fine :

Set Verbatim = 0;

To count spaces of each record, i created a new column using :

substringcount(Siege,' ') as Hierarchie,

Capture2.PNG.png

I can retrieve the correct number of leading spaces for the first three records. It doesn't work for the last one because i don't want to count space between 'S4' and 'London' but only before 'S4'.


So how can I only count leading spaces in a string ??

Thank You for your help

1 Solution

Accepted Solutions

Re: Count leading spaces in a string

( len(Siege) - (len( ltrim(Siege))))

3 Replies

Re: Count leading spaces in a string

( len(Siege) - (len( ltrim(Siege))))

bfournet
New Contributor II

Re: Count leading spaces in a string

Hello, it works fine and the solution more simple than I expected

Thank you !

Re: Count leading spaces in a string

Hi,

maybe this thread is also of interest for you:

loading data

hope this helps

regards

Marco

Community Browser