Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Multiple IF statement for the complex calculation

Hi I am trying to add multiple if conditions for the below task as hand:

if d<30

result=([90+(Rent-8000)]/1000)*3

else if 30<d<60

result=([100+(Rent-8000)]/1000)*3

else if 60<d<90

result=([110+(Rent-8000)]/1000)*3

else

result=([150+(Rent-8000)]/1000)*3

I tried this using multiple if statement in the script editor LOAD. However, I get error if I try to use multiple conditions under one if statement.

Could any one please help me to work on the right approach towards this issue ?

Thanks!

1 Solution

Accepted Solutions
Anil_Babu_Samineni

As i mention below thread, Assume that is not a field. use second condition that is the case. And [] - Indicates single field with in Qlik

Dual if statement with multiple conditions

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)

View solution in original post

5 Replies
oknotsen
Master III
Master III

Instead of "else if" you will have to nest your if-statements.

I am also not sure if "30<d<60" would work to begin with.

For starters, if d is 30 or 60, it would get the highest result, which would be wrong.

Try something like this:

if(d<30, ([90+(Rent-8000)]/1000)*3, if(d<60, ([100+(Rent-8000)]/1000)*3, if(d<90, ([110+(Rent-8000)]/1000)*3, ([150+(Rent-8000)]/1000)*3))) as result,

May you live in interesting times!
Not applicable
Author

Tried this but it's giving the below error:

Script Error:

Field not found - <90+(Rent-8000)>

Calculations:

LOAD

  d,

  if(d<30, ([90+(Rent-8000)]/1000)*3, if(d<60, ([100+(Rent-8000)]/1000)*3, if(d<90, ([110+(Rent-8000)]/1000)*3, ([150+(Rent-8000)]/1000)*3))) as result

  Resident RentCal

Anil_Babu_Samineni

As i mention below thread, Assume that is not a field. use second condition that is the case. And [] - Indicates single field with in Qlik

Dual if statement with multiple conditions

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
oknotsen
Master III
Master III

So apparently Rent is not a field in the table you are using this IF-statement on.

May you live in interesting times!
oknotsen
Master III
Master III

Never EVER start a topic twice again as it results in at least half the people wasting their time on a topic that is already being answered elsewhere.

Dual if statement with multiple conditions

Topic locked.

May you live in interesting times!