Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Rename field

Hi,

I'm trying to do something like this:

if campo='account' then campo rename to c_account

then if campo='lead' then campo as c_lead

then if campo='contact' then campo as c_contact

So, I would like to rename the field depending on values that cointains: if it contains n possible values i would like to obtaining n new fields.

Can I do this in qv script? How?

Thank you!

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Stupid question, I'm sorry.

I do in this way:


if (relmodule='Accounts', relcrmid) as c_azienda,

if (relmodule='Leads', relcrmid) as c_lead,

if (relmodule='Contacts', relcrmid) as c_contatto,

View solution in original post

2 Replies
Anonymous
Not applicable
Author

Stupid question, I'm sorry.

I do in this way:


if (relmodule='Accounts', relcrmid) as c_azienda,

if (relmodule='Leads', relcrmid) as c_lead,

if (relmodule='Contacts', relcrmid) as c_contatto,
Not applicable
Author

Hi,

I think that this solution could work (I suppose that your field is in a table "table_name") :

// Get the list of different values in the field

Temp_List_Values:

LOAD CONCAT(DISTINCT campo, chr(39)&','&chr(39)) as temp_list

RESIDENT table_name;

LET LIST_OF_CAMPO = chr(39) & peek('temp_list',0,'Temp_List_Values') & chr(39);

FOR EACH i IN $(LIST_OF_CAMPO)

     LET FINAL_FIELD_NAME = 'c_$(i)';

     $(FINAL_FIELD_NAME):

     LOAD campo as "$(FINAL_FIELD_NAME)"

     RESIDENT table_name

     WHERE campo = '$(i)';

NEXT

This script create one table per value of campo with the correct. But you could add more fields and do a work to build your model.