Skip to main content
Participant
June 27, 2024
Answered

If Else statement with multiple outcomes.

  • June 27, 2024
  • 1 reply
  • 823 views

So I'm I need a formula for an If Else statement where if Cell 1 equals a value the output changes.

So to make it simple Cell 1 has a value entered between 1-12. I need the values to output as such:

 

If Cell 1 = 1-6 Cell 2 = 0

If Cell 1 = 7-8 Cell 2 = 1

If Cell 1 = 9-10 Cell 2 = 2

If Cell 1 = 11+ Cell 2 = 3

 

I started by making Cell 1 and number variable, and I got a basic If Else statement to work for a single variable but I can't get it to work for multiple.

This topic has been closed for replies.
Correct answer try67

You can use this code as the custom calculation script of "Cell 2". The last line takes care of the case where "Cell 1" is empty (or zero), which you didn't specify in your post:

 

var cell1 = Number(this.getField("Cell 1").valueAsString);
if (cell1>=1 && cell1<=6) event.value = 0;
else if (cell1>=7 && cell1<=8) event.value = 1;
else if (cell1>=9 && cell1<=10) event.value = 2;
else if (cell1>=11) event.value = 3;
else event.value = "";

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
June 27, 2024

You can use this code as the custom calculation script of "Cell 2". The last line takes care of the case where "Cell 1" is empty (or zero), which you didn't specify in your post:

 

var cell1 = Number(this.getField("Cell 1").valueAsString);
if (cell1>=1 && cell1<=6) event.value = 0;
else if (cell1>=7 && cell1<=8) event.value = 1;
else if (cell1>=9 && cell1<=10) event.value = 2;
else if (cell1>=11) event.value = 3;
else event.value = "";
Participant
November 19, 2024

Hello,

 

I have a similar challenge and I tried applying the above concept but still not getting the desired results.

 

Total_Score1

Performance_Rating1

22-24

EE

16-21

ME

10-15

NI

0-9

DNM

 

I tried using this on my Adobe Form to populate field "Performance_Rating1"

if ("TOTAL_SCORE1" > 21){ event.value = "EE";

} else if ("TOTAL_SCORE1" > 15){ event.value = "ME";

} else if ("TOTAL_SCORE1" > 9){ event.value = "NI";

} else event.value = "DNM";

 

The only result I am getting is "DNM"

try67
Community Expert
Community Expert
November 19, 2024

To access a field's value it's not enough to just write out the field's name. You must use getField("FieldName").value, just like in the example above.