Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
shabarish0587
Contributor
Contributor

How to write multiple if conditions in script

HI Friends,

              I am trying to write multiple if conditions, if i use one condition i am getting value, but when i am using mutiple conditions i am not getting the value. can any one help me on this. i am sharing sample condition how i written. I have columns like

Status, Comment and Rejected_Rsn. By using these columns i need to write conditions.

Sample:

1) if(status='rejected', if(Rejected_Rsn='id submitted with error', if(wildmatch(Comment ,'*Invalid*','*rejected*'),'Incorrect Value','Ignore'))) as Flag1       // when i written above condition like this i am getting value as expected but when i am adding another condition i am not getting any value in Flag

2) if(status='rejected', if(Rejected_Rsn='id submitted with error', if(wildmatch(Comment ,'*Invalid*','*rejected*'),

if(status='rejected', if(Rejected_Rsn='Not to Fix', if(wildmatch(Comment ,'*valid*','*Closed*','*Not to Fix*')

'Incorrect Value','Ignore'

)))

))) as Flag1 

when i was trying second condtion i am not getting values. can any one please help me on this. i have used and/or also i am getting error. Thanks in Advance

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Your second expression first tests for Rejected_Rsn='id submitted with error' and again tests Rejected_Rsn for another value: Rejected_Rsn='Not to Fix'. Since a field can only contain one value and not two the result is the combination of these tests is always false. That's why you don't get a result.

Try this instead:

if(status='rejected'
    , if(Rejected_Rsn='id submitted with error'
        , if(wildmatch(Comment ,'*Invalid*','*rejected*')
            ,'Incorrect Value'
            ,'Ignore'
            )
        , if(Rejected_Rsn='Not to Fix'
            , if(wildmatch(Comment ,'*valid*','*Closed*','*Not to Fix*')
                ,'Incorrect Value'
                ,'Ignore'
                )
            )
        )
  ) as Flag1  

 


talk is cheap, supply exceeds demand

View solution in original post

3 Replies
PrashantSangle

try below

if(status='rejected',
if((Rejected_Rsn='id submitted with error' and wildmatch(Comment ,'*Invalid*','*rejected*')) or (Rejected_Rsn='Not to Fix' and wildmatch(Comment ,'*valid*','*Closed*','*Not to Fix*')),'Incorrect Value','Ignore'))
as Flag1

Note : Please check with closing bracktes.

If above solution won't work, then share your logic in simple words.

Regards,
Prashant Sangle
Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Gysbert_Wassenaar

Your second expression first tests for Rejected_Rsn='id submitted with error' and again tests Rejected_Rsn for another value: Rejected_Rsn='Not to Fix'. Since a field can only contain one value and not two the result is the combination of these tests is always false. That's why you don't get a result.

Try this instead:

if(status='rejected'
    , if(Rejected_Rsn='id submitted with error'
        , if(wildmatch(Comment ,'*Invalid*','*rejected*')
            ,'Incorrect Value'
            ,'Ignore'
            )
        , if(Rejected_Rsn='Not to Fix'
            , if(wildmatch(Comment ,'*valid*','*Closed*','*Not to Fix*')
                ,'Incorrect Value'
                ,'Ignore'
                )
            )
        )
  ) as Flag1  

 


talk is cheap, supply exceeds demand
shabarish0587
Contributor
Contributor
Author

Thank You Gysbert