Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Script problem in if condition

Hi,

I have columns like Linkid,state,end1,end2.

Linkid contains numbers like 1...10.

state contains 0,1,2 ,1,0,1,1,0,2,1

end1 contains Yes,No like repetitively upto 10 rows

end2 also contains Yes,No upto 10 rows.

Now my requirement is i need to divide state into 4 stages based on state,end1,end2.

Stage0 =total count of linkid.

Stage1=selection of state(0,1)

Stage2=selection of state(0,1) and end1(Yes)

Stage3=selection of state(0,1) and end1(Yes) and end2(Yes)

The above i have created in script like

if(state=0 and state=1,'Stag1',

     if(state=0 and state=1 and end1='Yes','Stag2',

     if(state=0 and state=1 and end1='Yes' and end2='Yes','Stag3'))) as Newstate,(I haven't included Stage0  could you please check)

After reloading i haven't got any data for newstate showing empty.May be i have done wrong in script part of if condition.

Please check attachment of excel data and qlikview file below.

Could you please help me on that with including Stage0?

Thanks,

Kanna

15 Replies
Anonymous
Not applicable
Author

Thanks for your help..I have 18000 records like that i can't create new stage for all

engishfaque
Specialist III
Specialist III

Dear Rajesh,

Then I think you need to use listed below IF else condition,

if(state=0 or state1=1 and end1='Yes' and end2='Yes','Stag3',

      if(state=0 or state1=1 and end1='Yes','Stag2',

      if(state=0 or state1=1,'Stag1'))) as Newstate

Kind regards,

Ishfaque Ahmed

Anonymous
Not applicable
Author

I tried that but it is loading only stage1 after reloading..it's not taking

stage2 and stage3.

PradeepReddy
Specialist II
Specialist II

try like this...

IF((State=0 or State=1) and end1='Yes' and end2='Yes','Stage3',

IF((State=0 or State=1) and end1='Yes' ,'stage2',

  IF((State=0 or State=1),'stage1')))   as NewState

engishfaque
Specialist III
Specialist III

Dear Rajesh,

Have you tried this expression as I share you in last post,

if(state=0 or state1=1 and end1='Yes' and end2='Yes','Stag3',

      if(state=0 or state1=1 and end1='Yes','Stag2',

      if(state=0 or state1=1,'Stag1'))) as Newstate

I have checked and found that it was working fine, reference screenshot is attached with this post. Please check.

output2.png

Kind regards,

Ishfaque Ahmed

ahmar811
Creator III
Creator III

Hello

rajeshlingutla1257

you cant write AND between two condition which have same field like in your script

state=0 AND state=1

try this expression in you load script

if(state=0 OR state=1,'Stag1',

if((state=0 OR state=1) AND end1='Yes','Stag2',

if((state=0 OR state=1) AND (end1='Yes' OR end2='Yes'),'Stag3'))) as Newstate

hope this help you

Thanks & Regards

Ahmar Ansari