Skip to main content
Known Participant
December 14, 2020
Question

Need help with a formula with a value that falls in a range of numbers

  • December 14, 2020
  • 2 replies
  • 566 views

I am converting an Excel file to Adobe and am working on the formulas based on Overall Score.  I have figured out how to write the formula for the 100% and the 0% bonus, but am having issues figuring out how to get the 80% and 60% answers. 

For my 100%, here is the formula:

if (Number(this.getField("Overall score").valueAsString)>199) event.value = "100%";
else event.value = "";

This gives me a blank value if the Overall score is less than 200, which is what I want.  I need to figure out how to get the 80% value if the overall score is >=180 and <=199, and a blank value if not in that range.  I have tried various formulas and either get syntax errors or illegal XML format. Thanks!

This topic has been closed for replies.

2 replies

Nesa Nurani
Community Expert
Community Expert
December 14, 2020

You should compare like this:

overall score >= 180 and overall score <= 199" and not like this overall score is >=180 and <=199.

See this example:

 

var score = Number(this.getField("Overall score").valueAsString);
if(score > 199){
event.value = "100%";}
else if(score >= 180 && score <= 199){
event.value = "80%";}
else event.value = "";

EDIT: Sorry didn't refresh page so I didn't see try67 already have posted answer.

 

 

Known Participant
December 15, 2020

Thank you!

try67
Community Expert
Community Expert
December 14, 2020

You can use this code to achieve it:

 

var score = Number(this.getField("Overall score").valueAsString);
if (score>199) event.value = "100%";
else if (score>=180) event.value = "80%";
else event.value = "";
Known Participant
December 15, 2020

Thanks!