Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

If then elseif

Hi there

I currently have the following within my script to load a qvd file :

if(CT_YEAR = 'C', 2010, if(CT_YEAR = 'L', 2009)) as [ACYear],

I'd like to cater for another option 'N' :

if CT_YEAR = 'C' then
ACYear = '2010'
elseif CT_YEAR = 'L' then
ACYear='2009'
elseif CT_YEAR = 'N' then
ACYear ='2011'
endif

Can anyone advise how to set this up within the load script?

Thanks

Bob

1 Solution

Accepted Solutions
Not applicable
Author

if(CT_YEAR = 'C','2010',if(CT_YEAR = 'L','2009',if(CT_YEAR = 'N','2011'))) as ACYear,

please try the above script .

View solution in original post

4 Replies
Not applicable
Author

if(CT_YEAR = 'C','2010',if(CT_YEAR = 'L','2009',if(CT_YEAR = 'N','2011'))) as ACYear,

please try the above script .

Not applicable
Author

Try



If

9999 is the catchall error

(CT_YEAR = 'C', '2010', If (CT_YEAR = 'L','2009', If (CT_YEAR = 'N','2011', '9999'))) As ACYear,



matt_crowther
Luminary Alumni
Luminary Alumni

I may be missing somehting but the way I'd do the above is:

=if(CT_YEAR = 'C','2010',if(CT_YEAR = 'L','2009',if(CT_YEAR = 'N','2011','Outside Range'))) as ACYear,

Just like a running IF expression in Excel.

Alternatively look into using a Mapping load and 'Apply Map' in the script.

Hope that helps,

Matt - Visual Analytics Ltd

Not applicable
Author

Hi

I tried the solution given by priyadashin and it worked fine. Thanks to everyone who replied.

Bob