Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Highlighted
apthansh
Contributor

If else condition

Can I put something like below condition ?

=if(GetFieldSelections(Status)='Active','1','A' or

    IF (GetFieldSelections(Status)='Closed','2','B' or

        IF  (GetFieldSelections(Status)='Pending','3','C' )))

Is anything wrong in the above condition ?It doesn't work..

6 Replies

Re: If else condition

Yes, the above isn't right because you have a true and false condition, but you are not ending your if statement

=if(GetFieldSelections(Status)='Active','1','A' or

    IF (GetFieldSelections(Status)='Closed','2','B' or

        IF  (GetFieldSelections(Status)='Pending','3','C' )))

Green is True, Red is False... it will show you an error after this

Re: If else condition

In addition to what Sunny already pointed out, there are too many options for some Status values.

For example, If Status = 'Closed' then the result can either be 'A' (because not 'Active') or '2' (because of the next IF). Which will it be?

apthansh
Contributor

Re: If else condition

thank you...how can i correct this ?is there a solution ?

Re: If else condition

Not really, because it isn't clear what value should go with which Status Code. Can you provide a table with two columns with in the rist column all Status codes (and a default entry for all other cases), and in the right column the corresponding expression result values. Then we can fix it.

effinty2112
Honored Contributor

Re: If else condition

Hi Ansh,

I can only guess what you're looking for but maybe this?

=if(GetFieldSelections(Status)='Active',Dual('A',1),

    if(GetFieldSelections(Status)='Closed',Dual('B',2),

       if(GetFieldSelections(Status)='Pending',Dual('C',3)))

Regards

Andrew

Re: If else condition

What about this if it matches with your requirement also check values after this may be it works.

=if( GetFieldSelections(Status)='Active','1' or GetFieldSelections(Status)='Active','A' or

if( GetFieldSelections(Status)='Closed','2' or GetFieldSelections(Status)='Closed','B' or

IF( GetFieldSelections(Status)='Pending','3' or GetFieldSelections(Status)='Pending','C' )))