Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

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
MVP
MVP

Re: IF THEN Statement to return a value

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....

7 Replies
sinanozdemir
Valued Contributor III

Re: IF THEN Statement to return a value

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);

MVP
MVP

Re: IF THEN Statement to return a value

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

Re: IF THEN Statement to return a value

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

Re: IF THEN Statement to return a value

Tried this, it gave me a syntax error

MVP
MVP

Re: IF THEN Statement to return a value

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
Valued Contributor III

Re: IF THEN Statement to return a value

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
Honored Contributor III

Re: IF THEN Statement to return a value

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);

  

Community Browser