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

If Else statement with multiple outcomes.

New Here ,
Jun 27, 2024 Jun 27, 2024

Copy link to clipboard

Copied

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

Views

50

Translate

Translate

Report

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

correct answers 1 Correct answer

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 = "";

Votes

Translate

Translate
Community Expert ,
Jun 27, 2024 Jun 27, 2024

Copy link to clipboard

Copied

LATEST

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 = "";

Votes

Translate

Translate

Report

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