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

replace column if exists

hi,

i had a question

i had a table like that:

Client2013     Client2014     Client2015

QUICK               -                   Mcdo

Flunch              KFC               QUICK

Eli                    -                         -

Elo                    Youk                    -

Mcdo                    -                    QUICK

i'd like to have a new column with conditions if there is somthing in client 2014 replace in client2013 and if exists client2015 replace client2014(with replace client2013 if exist)

to resume, the result should be:

NvClients

Mcdo

QUICK

Eli

Youk

QUICK

how can i do? THANKS a lot and sorry for my bad english

11 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

load

     Client2013,

     Client2014,

     Client2015,

     if(len(trim(Client2015)),Client2015,

          if(len(trim(Client2014)),Client2014,Client2013)) as NvClients

from ...


talk is cheap, supply exceeds demand
Not applicable
Author

thanks a lot but just a problem,

When Client2014 and Client 2015 not exists (Client2013 always exists) the result is "-" but i want Client2013

Exemple:

Client2013     Client2014     Client2015

Eli                    -                         -


With your script that give me "-" but i want "Eli" for the rest this is perfect! thanks

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try:

load

     Client2013,

     Client2014,

     Client2015,

     if(len(trim(Client2015)) and Client2015 <> '-',Client2015,

          if(len(trim(Client2014)) and Client2014 <> '-',Client2014,Client2013)) as NvClients

from...


talk is cheap, supply exceeds demand
Not applicable
Author

Okay i understand the problem

when the name is too long because i had 1000 names, thats not put it in nvclient, may be beccause of len?

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Could be. You can try the IsNull function instead of len(trim(...)).


talk is cheap, supply exceeds demand
Not applicable
Author

OKAY i gat the solution, i delete "len" and its ok! thank you very much!!!

Not applicable
Author

Arf sorry but it's not ok xD

Not applicable
Author

LOAD [Client2013 ],

     Client2014,

     Client2015,

     if(len(trim(Client2015))=0,Client2014,if(len(trim(Client2014)=0),[Client2013 ])) as NvClients

use this may help you.

sasikanth
Master
Master

LOAD  * Inline [
Client2013   ,  Client2014  ,   Client2015
QUICK    ,           -       ,     Mcdo
Flunch    ,          KFC       ,   QUICK
Eli      ,              -       ,  -
Elo      ,              Youk     ,    -
Mcdo     ,               -        ,  QUICK
]
;





LOAD
if(Client2015<>'-',Client2015,
if( Client2015='-',if( Client2014='-',Client2013,Client2014),Client2014)) as nta
Resident tab;