Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Inserire Nuovo Campo

Ciao,

credo sia una domanda abbastanza semplice, ma non riesco a risovere il mio problema.

Io carico da file excel i dati con il seguente script:

LOAD *

FROM

C:\....dati.xlsx

(

ooxml, embedded labels);

In questo file è presente un campo DATA con formato tipo AAAAMMGG.

Vorrei creare un campo aggiuntivo "ANNO" con il solo anno. Credo sia necessaria la funzione left.

Come posso modificare il mio script?

Grazie mille

8 Replies
pat_agen
Specialist
Specialist

ciao Marco,


due possibilités

quando qlikview videre el campo DATA como tipo Date possere scrivere

load
year(DATA) as Anno
from ...;

quando qv non videre el campo DATA como tipo Data ma como tipo Texto possere scrivere

load
mid(DATA,1,4) as Anno
from ...;

esperiamo ti assistenza!

Not applicable
Author

Ok, Grazie!!

Io pero voglio importare tutti i campi e anche il campo Anno.

Se nella parte Modifica Script scrivo:

load *, mid(DATA,1,4) as Anno
from ...;

Non funziona!

Grazie per la risposta

brenner_martina
Partner - Specialist II
Partner - Specialist II

Hi,

it would be nice, if you use this forum only in english!

pat_agen
Specialist
Specialist

Marco,

I have to see your qvw to understand the issue. Can you post it ?

The load command should have worked - did you try as it looks below?

LOAD * ,

mid(DATA,1,4) as Anno

FROM C:\....dati.xlsx (ooxml, embedded labels);

Not applicable
Author

Sorry Martina..

Yes this is my problem.

The load command that you write, work for all variables of my database...but not for variable DATA. The correct name is DATA PASS. SOFF. (it's important)

The Variable DATA PASS. SOFF. my be have the same name of an other default variable (DATA). I can't change that name.

So if i use your command for other varibles like NAME, ADDRESS correctly it returns the first 4 letters or numbers, but if i try to use the MID function for the variable DATA PASS. SOFF. it doesn't work.

Error message:

Error in expression:
')' expected
LOAD *, mid(data pass. soff., 4,1)

FROM
C:\....work.xlsx
(ooxml, embedded labels)

Thank you

pat_agen
Specialist
Specialist

hi,

it would be easier if you attach an example qvw to your message.

The issue may e wit th ename of your field. The field name contains spaces and special characters so putting square brackets around the name may help You shoudl also use the renaming like below

OldfiedlName as NewFieldName

Try this

LOAD *,
mid([data pass. soff.], 1,4) as Anno

FROM
C:\....work.xlsx
(ooxml, embedded labels)

if you still have an issue try and post your qvw. that will make it easier to help you.

Not applicable
Author

Ok, it's perfect!

Thank you PatAgen. Grazie mille!!

pat_agen
Specialist
Specialist

finalmente!

Tutto è bene quel che finisce bene