Nested IF's and Or's > validating multiple dropdown options

  • 12 August 2019
  • 6 replies
  • 2 views

Badge +11

Hello

 

I have 5 seperate dropdown options which allows you to select 1 to 5 range.
My idea is to come up with a EndResult depending on the selected options.

 

The criteria to meet the EndResult: X | Y | Z

 

X means if Option1 is either 4 or a 5

Y means if Option1 is either 2 or 3 AND Option3 is 4 or 5

Z means if Option1 is either 3 or 2 or 1 AND Option3 is either 3 or 2 or 1 AND Option5 is either 4 or 5

 

Anything else outside the above range is "Normal"

 

How to do that? It requires nested IF statements and I get lost in it.

My initial start ... :

 

if(or(Option1=="4", Option1=="5"),"Big", "Normal")

 

Would appreciate your advise.


6 replies

Badge +11
if(or(Option1=="4", Option1=="5"),"X", "Normal")
Badge +11

Anybody can assist?

I got the 1st and 2nd option fixed.

 

X Option

if(or(parseLookup(Q1_Option)=="4", parseLookup(Q1_Option)=="5"),"X Option", "Normal")

 

 

Y Option

if(and(or(parseLookup(Q1_Option)=="2", parseLookup(Q1_Option)=="3") , or(parseLookup(Q3_Option)=="4", parseLookup(Q3_Option)=="5")),"Y Option", "Normal")

 

Z Option

This is where I am struggling .... the or() & and() seem to look at only two possible outcomes.

How do I nest that above to match the Y criteria?

 

Userlevel 5
Badge +14

How are you displaying the results? Inside of a Calculated Control perhaps? 

Is it supposed to return the String "X", "Y", or "Z" based on your formula? 


Userlevel 6
Badge +22

Hi,

 

I gave this a go and this is what I came up with:

If(op1>3,"X",(If((op1>1 && op1<4)&&(op3>3),"Y",If(((op1>0) && (op1<4))&&((op3>0) && (op3<4))&&(op5>3),"Z","Normal"))))

I could have used runtime functions through out the formula but it would have been 10 times longer.

Attached a demo form showing this working.

Badge +11

@MegaJerk 

 

Correct, I am using a calculated formula within the form.
Since, I was strugling to get everything working in one calculcated value ; instead I have added three fields for X Y Z in this example

 

So, the first two X and Y fields work fine and now struggling with Z option as I cannot it to work when three condition meet e.g. when Option 1 and 2 and 3 meet the criteria.

 

 

Badge +11

@SimonMuntz 

 

Excellent, works like butter on toast :)
I could not have come up with that formula, by myself.

 

Cheers

Reply