2 Replies Latest reply on May 16, 2016 1:53 PM by ChristinaDuckworth

# Auto create value in one field based upon percentage range in another field

Good morning, forum folks!  I am trying to create a field which populates a score based on the percentage in another field.  To that end, I have a field which autocalculates a percent based upon two other fields.  I would like a third field which, for instance, rates less 75% as a 2 ... 75 - 85% as a 3 .. and greater than 85% as a 4.  I cannot figure out the syntax to make this happen, can any of you help?

For edification, my percentage field looks like:

//Rock Percentage Calculation – use Number Format “Percentage”

if (this.getField("RockTotalQ").value==0) {
event.value = 0;
} else {
event.value = this.getField("RockComplQ").value/this.getField("RockTotalQ").value;
}

Thankyou.

• ###### 1. Re: Auto create value in one field based upon percentage range in another field

So you can use something like this as the custom calculation script of the other field (make sure it appears after the "Rock Percentage" field in the calculation order, though!):

```var v = this.getField("Rock Percentage").valueAsString;
if (v=="") event.value = "";
else {
v = Number(v);
if (v<=0.75) event.value = 2;
else if (v<=0.85) event.value = 3;
else event.value = 4;
}
```
• ###### 2. Re: Auto create value in one field based upon percentage range in another field

Works like a charm!  Thanks so much!