Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to add a new field according to a condition

Good morning,

I have table with 10 fields, one of them named "Mercado". I would like to add to the same table a new filed (the eleventh one) called "grupo_mercado" which would be filled with values according to the values existing in "Mercado".

If Mercado='GEN' OR Mercado='GRA' OR Mercado='LOC' THEN grupo_mercado='C'...

I was not able to script this correctly with the Qlikview help neither with QV reference manual.

Can anybody help me?

Thank you.

1 Solution

Accepted Solutions
rajni_batra
Specialist
Specialist

keep it into one expression only(multiple ifs)...

IF(MATCH(MER_CODIGO,'GRA','GEN','DIR','GPIÑERO','LOC','LOCMEX','MEX','RECP'),'C',

    IF(MATCH(MER_CODIGO,'ESP'),'B','A') AS MER_GRUPO

View solution in original post

5 Replies
Not applicable
Author

Hi,

if you are in V11, you can do it under the "condition" field.

rajni_batra
Specialist
Specialist

Use

if(match(mercado,'GEN',GRA,LOC),'C')and so on ur conditions as grupo_mercado

Not applicable
Author

I wrote this into the load sentence after load the field MER_CODIGO:

 

IF(MATCH(MER_CODIGO,'GRA','GEN','DIR','GPIÑERO','LOC','LOCMEX','MEX','RECP'),'C') AS MER_GRUPO,
IF(MATCH(MER_CODIGO,'ESP'),'B') AS MER_GRUPO

If this is correct, how could I make to fill the value 'A' for all  the rest of records which are not 'B'or 'C' ?

Thank you very much

rajni_batra
Specialist
Specialist

keep it into one expression only(multiple ifs)...

IF(MATCH(MER_CODIGO,'GRA','GEN','DIR','GPIÑERO','LOC','LOCMEX','MEX','RECP'),'C',

    IF(MATCH(MER_CODIGO,'ESP'),'B','A') AS MER_GRUPO

Not applicable
Author

Perfect. Thank you.