Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Supertendi
Contributor II
Contributor II

Rename data in field

Hi everyone,

I have some data in one field called "Ires" and "Irap" and i want to change their name in "Imposte". the field is named "DESC_GRP".

this is my script that doesn't work

 

Tabella_riclassificato:
LOAD DESC_GRP,
If(DESC_GRP='Ires','Imposte',IF(DESC_GRP='Irap','Imposte',DESC_GRP)) AS DESC_GRP;

SQL SELECT IND, TIPO, CODICE, DESCRIZIONE, SUBTOTALI, GRUPPO, CDC_SBT, DESC_GRP, CONTO_RICLASSIFICATO
FROM GIMETAL_RICLASSIFICATO

any idea?

THANKS

 

 

 

8 Replies
Taoufiq_Zarra

@Supertendi 

to rename fialed use

Rename Field XXX to YYYY;

and if I understtod correctly

LOAD *,
If(DESC_GRP='Ires','Imposte',IF(DESC_GRP='Irap','Imposte',DESC_GRP)) AS DESC_GRP;

SQL SELECT IND, TIPO, CODICE, DESCRIZIONE, SUBTOTALI, GRUPPO, CDC_SBT, DESC_GRP, CONTO_RICLASSIFICATO
FROM GIMETAL_RICLASSIFICATO
Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
edwin
Master II
Master II

Your post title is a little bit misleading.  what you really wanted was transform your data.  the if statement in your script is correct.  however, the problem is that you are naming the transformed field the same as an existing field.  QV will not allow the same field name used more than once.  how about:


Tabella_riclassificato:
LOAD DESC_GRP,
If(DESC_GRP='Ires','Imposte',IF(DESC_GRP='Irap','Imposte',DESC_GRP)) AS DESC_GRP_TRANSFORMED;

....

Supertendi
Contributor II
Contributor II
Author

I would like to maintain the same name because I have several expressions working with this field name.

Kushal_Chawda

@Supertendi  You could write match function as well to simplify . Also try to use trim with lower function to make sure that it should written value when there is white spaces or case mistamtch

LOAD *,
If(match(lower(trim(DESC_GRP)),'ires','irap'),'Imposte',DESC_GRP)) AS DESC_GRP;

SQL SELECT IND, TIPO, CODICE, DESCRIZIONE, SUBTOTALI, GRUPPO, CDC_SBT, DESC_GRP, CONTO_RICLASSIFICATO
FROM GIMETAL_RICLASSIFICATO;

 

edwin
Master II
Master II

you cant have the same field name twice in same table.  you can switch the field names if you want:

Tabella_riclassificato:
LOAD DESC_GRP as SOMEOTHERNAME,
If(DESC_GRP='Ires','Imposte',IF(DESC_GRP='Irap','Imposte',DESC_GRP)) AS DESC_GRP;

.

edwin
Master II
Master II

this will fail as DESC_GRP will appear twice

Supertendi
Contributor II
Contributor II
Author

Hi,

it says syntax error: FROM missing or misplaced...

Chanty4u
MVP
MVP

sql.PNG