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
engishfaque
Specialist III
Specialist III

Dear Rajesh,

I have checked your if else condition,

I think you need to use OR Operator instead of AND Operator between state =0 and state =1

This is not possible to use AND Operator on the same field such as you have done, state field either be 0 or 1.

How the same field can be 0 and 1 at the same time?

Kindly find attached file.

Kind regards,

Ishfaque Ahmed

Anonymous
Not applicable
Author

If I am including both we need to put AND only na..OR we use of either this

or another.

engishfaque
Specialist III
Specialist III

Dear Rajesh,

Here is the AND Operator output,

 

statestate1output
000
010
100
111

Here is the OR Operator output,

 

statestate1output
000
011
101
11

1

Then how can be possible that you are saying state = 0 and state = 1 ?

You can apply AND Operator in that way state = 0 AND state1 = 1.

Kind regards,

Ishfaque Ahmed

Anonymous
Not applicable
Author

Thanks for your response.

Here 1 and 0 are not Boolean values ..I can also take 1 and 2 also any

numbers that time not possible.

engishfaque
Specialist III
Specialist III

Dear Rajesh,

Here is your excel file data,

 

linkidstateend1end2
10YesYes
21YesNo
31NoNo
52YesYes
61NoNo
42NoYes
30YesYes
41YesNo
60NoYes
40YesYes
32NoYes

state is a field where you are applying AND Operator. So I'm telling you this is not possible at the same time state contain 0 and 1. state either be 0 or 1 at a time.

Solution: create one more state1 field where you put your 1 or 2 values and then perform AND operation in IF else condition. Such as I illustrated in previous post.

Kind regards,

Ishfaque Ahmed

Anonymous
Not applicable
Author

Can you please help me on writing sample data to load including state2 and

also script part with stages I have asked in requirement, that should be

very helpful for me.

Thanks,

Rajesh

engishfaque
Specialist III
Specialist III

Dear Rajesh,

Sure, please share me your desired output.

Kind regards,

Ishfaque Ahmed

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,

Kindly find attached App, I hope you are looking for that one solution.

Kind regards,

Ishfaque Ahmed