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 Statement to return a value

I have the following data that I am importing and need to return a certain value in SWEEP_STATUS if the CUST_NBR matches a certain customer, but if it does not match I just want the normal results.  Here is my script and it is telling me garbage after load.  What am I doing wrong?  nd do I have the IF THEN statement in the right place to begin with?

LOAD

     COMMITMENT_ID,
     SWEEP_STAT,
    
CUST_NBR,

FROM
[$(vFromQVD)\HRC_LIABILITIES.qvd](
qvd)

IF((
[CUST_NBR] = '0450011670') THEN ([SWEEP_STATUS]='Yes'));

Store HRC_LIABILITIES_ORIGINAL into  [$(vToQVD)\HRC_LIABILITIES_SWEEP_STATUS_CHANGE.qvd](qvd);

1 Solution

Accepted Solutions
maxgro
MVP
MVP

it depends, you have many options

// yes for 0450011670, no for ll others

IF(CUST_NBR = '0450011670', 'Yes', 'No') as SWEEP_STAT,


// yes for .........., null for .........

IF(CUST_NBR = '0450011670', 'Yes') as SWEEP_STAT,


// yes for ......, SWEEP_STAT for other

IF(CUST_NBR = '0450011670', 'Yes', SWEEP_STAT) as SWEEP_STAT,


// 2 fields

SWEEP_STAT,

IF(CUST_NBR = '0450011670', 'Yes', 'No') as SWEEP_STAT2,


// etc....

View solution in original post

7 Replies
sinanozdemir
Specialist III
Specialist III

Hi Jonathan,

Try this:

LOAD

     COMMITMENT_ID,
     SWEEP_STAT,
    
CUST_NBR,
    IF(([CUST_NBR] = '0450011670') THEN ([SWEEP_STATUS]='Yes'))
FROM
[$(vFromQVD)\HRC_LIABILITIES.qvd](
qvd);

maxgro
MVP
MVP

LOAD

    COMMITMENT_ID,
    //SWEEP_STAT,

    IF(CUST_NBR = '0450011670', 'Yes', 'No') as SWEEP_STAT,
   
CUST_NBR

FROM
[$(vFromQVD)\HRC_LIABILITIES.qvd](
qvd)

Store HRC_LIABILITIES_ORIGINAL into  [$(vToQVD)\HRC_LIABILITIES_SWEEP_STATUS_CHANGE.qvd](qvd);

Not applicable
Author

Will this make my SWEEP_STAT populate as 'No' for everything else that is not that particular customer?  Because some could be yes and others no and I want both in there, but I just want that specific customer to all be 'Yes'.

Not applicable
Author

Tried this, it gave me a syntax error

maxgro
MVP
MVP

it depends, you have many options

// yes for 0450011670, no for ll others

IF(CUST_NBR = '0450011670', 'Yes', 'No') as SWEEP_STAT,


// yes for .........., null for .........

IF(CUST_NBR = '0450011670', 'Yes') as SWEEP_STAT,


// yes for ......, SWEEP_STAT for other

IF(CUST_NBR = '0450011670', 'Yes', SWEEP_STAT) as SWEEP_STAT,


// 2 fields

SWEEP_STAT,

IF(CUST_NBR = '0450011670', 'Yes', 'No') as SWEEP_STAT2,


// etc....

sinanozdemir
Specialist III
Specialist III

My bad, I wasn't quite carefull:

LOAD

     COMMITMENT_ID,
     CUST_NBR,
    IF([CUST_NBR] = '0450011670', 'Yes', SWEEP_STAT) AS SWEEP_STAT
FROM
[$(vFromQVD)\HRC_LIABILITIES.qvd](
qvd);


Hopefully, this should do it.

sasiparupudi1
Master III
Master III

Try this..It will store 'Yes' for the CUST_NBR '0450011670' and 'No' for all the others in to the field SWEEP_STATUS


LOAD

     COMMITMENT_ID,
     SWEEP_STAT,
    
CUST_NBR,
    IF([CUST_NBR] = '0450011670' ,'Yes','No') as [SWEEP_STATUS]
FROM
[$(vFromQVD)\HRC_LIABILITIES.qvd](
qvd);