Copy link to clipboard
Copied
Hello,
I have a series of fields that require a yes, no, n/a answer from a drop down. Then I need to auto calculate the # of times 'Yes' is selected divided by the number of Yes's and No's (but excludes adding the na's into the denominator). Numerator=Countif("yes")/Denominator=Countif("yes" or "no").
Thanks
OK, then you can use this code as the custom calculation script of the field where you want the result to appear (PC MCKTOTAL):
var totalYes = 0;
var total = 0;
for (var i=1; i<=5; i++) {
var f = this.getField("PC MCKRow"+i);
if (f.valueAsString=="Yes") {
totalYes++;
total++;
} else if (f.valueAsString=="No") {
total++;
}
}
if (total==0) event.value = "";
else event.value = totalYes / total;
Copy link to clipboard
Copied
What are the names of the fields involved?
Copy link to clipboard
Copied
PC MCKRow1, PC MCKRow2, PC MCKRow3, PC MCKRow4, PC MCKRow5 (Yes, No, NA). PC MCKTOTAL (%)
Copy link to clipboard
Copied
OK, then you can use this code as the custom calculation script of the field where you want the result to appear (PC MCKTOTAL):
var totalYes = 0;
var total = 0;
for (var i=1; i<=5; i++) {
var f = this.getField("PC MCKRow"+i);
if (f.valueAsString=="Yes") {
totalYes++;
total++;
} else if (f.valueAsString=="No") {
total++;
}
}
if (total==0) event.value = "";
else event.value = totalYes / total;
Copy link to clipboard
Copied
You're Awesome! Thank you, it worked.
Copy link to clipboard
Copied
I need some help that is similar to this question.
I have 10 drop down boxes with -,yes,no. The boxes are labeled Is salesman Behind on Route_1, Is salesman Behind on Route_2, all the way to 10. Some boxes will have just a - in them.
I need when they click on yes to add 1 and no or - would be 0.
Would it be the same as above? And I know I would need to change the field name.
Copy link to clipboard
Copied
Yes, very similar... Try this:
var totalYes = 0;
var total = 0;
for (var i=1; i<=10; i++) {
var f = this.getField("Is salesman Behind on Route_"+i);
if (f.valueAsString=="yes") {
totalYes++;
total++;
} else {
total++;
}
}
if (total==0) event.value = "";
else event.value = totalYes / total;
Copy link to clipboard
Copied
Is there a script to have just one box display a percentage from the total sum that I can use?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now