Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
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

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful

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

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
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!