Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Load field with inizial space

Good Morning,

i have a database SQL with a table with two fields (Code - char 20 / Description - char 40). Sometimes the Code field is populated not from column 1 (see examples) and when i LOAD the Code field in Qlikview the initial spaces are left out.

Example column CODE Load in Qlikview

001 002 01 001 002 01

001 02004 001 02004

002 01 002 01

I would like the LOAD command to respect the data of the database:

Load in Qlikview

001 002 01

001 02004

002 01

How can i do it ?

Thank You

Paolo

Tags (1)
1 Solution

Accepted Solutions
mov
Esteemed Contributor III

Load field with inizial space

Paolo,
The first thing to try is to use text() function:
text(CODE) as CODE.

(On the other hand - why do you want this? Maybe you're trying to fix the wrong problem...)

9 Replies
mov
Esteemed Contributor III

Load field with inizial space

Paolo,
The first thing to try is to use text() function:
text(CODE) as CODE.

(On the other hand - why do you want this? Maybe you're trying to fix the wrong problem...)

Not applicable

Load field with inizial space

I try but the problem is not solve.

I want this because the first 3 characters are the sizes of the Article, the next 1 is the model, the next 3 are the colours ecc...

When i want to analize the sizei must have the exact code ("001"," 00", " ") to retrieve the description of the code (i could have article without size).

Why Qlikview LOAD in this way ?

Thank You

Paolo

mov
Esteemed Contributor III

Load field with inizial space

So, are these columns (Article, model, etc.) are all concatenated in one field in the database?
Looks really strange, but still shouldn't be a big deal, if you know exactly the order and length of the parts. You can use len() and mid() functions in this case to cut it in the correct pieces.

Not applicable

Load field with inizial space

The "Article" value is in another field.

I resolve the problem with the command replace to substitute " " with "_".

But i don't understand because Qlikview cut off the space:it does not an error ?

Thank You

P.S.

I have the same case if i fill an Excel fle in the same way.

mov
Esteemed Contributor III

Load field with inizial space

the questions "why" don't have technical answers... Tongue Tied
Qlikview, like Excel, "assumes" that if all characters are numbers, the whole data piece is numeric. Both cut off the lesding spaces and 0's. So, we have to use some additional measures if it it's not a number...

Not applicable

Load field with inizial space

I try to input in fileld Code only character (replace the number) with initial spaces but the result is the same: Qlikview cut off the initial spaces.

The same test in Excel: i input " A" (three initial spaces) in column A and when i load in QLIKVIEW the value was "A" without the initial spaces.

Why ?

Thank You

Paolo

mov
Esteemed Contributor III

Load field with inizial space

That's a good question for QlikTech. There is function trim() that eliminates leading and trailng spaces - that implies that they should not be eliminated by default...

Not applicable

Load field with inizial space

I found the variable "Verbatim" in the manual.

At the start of the script i must write "Set Verbatim = 1" and Qlikview don't cut off the initial spaces.

Thank You

Paolo

mov
Esteemed Contributor III

Load field with inizial space

Good to know. Smile
Thanks Paolo

Community Browser