Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

If Else statement with multiple outcomes.

New Here ,
Jun 27, 2024 Jun 27, 2024

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.

TOPICS
How to
726
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Jun 27, 2024 Jun 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 = "";

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 27, 2024 Jun 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 = "";
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 18, 2024 Nov 18, 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"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 19, 2024 Nov 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 19, 2024 Nov 19, 2024
LATEST

Thank you that was exactly what I missed!!

 

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

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

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

else event.value = "DNM";

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines