Discussion Board for collaboration on QlikView Scripting.
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?
Go to Solution.
Stupid question, I'm sorry.
I do in this way:
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
LOAD CONCAT(DISTINCT campo, chr(39)&','&chr(39)) as temp_list
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)';
LOAD campo as "$(FINAL_FIELD_NAME)"
WHERE campo = '$(i)';
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.