Skip to main content
Participant
May 16, 2024
Question

Need help calculating the "average" of dropdown selections

  • May 16, 2024
  • 1 reply
  • 315 views

I have created a document in Adobe Acrobat and need to figure out how to calculate the average of a bunch of dropdown lists. There are a total of 16 different dropdowns all named as Rating1, Rating2, Rating 3, etc. Below are the Options and their Export Values:

 

  • Below Expectations = 1
  • Not Meeting Expectations = 2
  • Meeting Expectations = 3
  • Exceeding Expectations = 4

 

I created a blank text field called Overall Rating and would like to calculate the average of the 16 selections made from the dropdowns. For example, if the below dropdowns were selected X amount of times multiplied by the value and divided by 16

 

  • Below Expectations selected 1 time (1 x 1 = 1)
  • Not Meeting Expectations selected 3 times (3 x 2 = 6)
  • Meeting Expectations selected 7 times (7 x 3 = 21)
  • Exceeding Expectations selected 5 times (5 x 4 = 20)
  • Overall Rating = Meeting Expectations (based on the "average" calculation of the export values which would be 48/16 = 3)

 

I have searched everywhere and can't figure out how to do this. I have no experience with JavaScript whatsoever. Is there a simple script I can write that would calculate this for me. Something like:

 

If average is 1 = Below Expectations

If average is 2 = Not Meeting Expectations

If average is 3 = Meeting Expectations

If average is 4 = Exceeding Expectations

 

Thank you in advance for any help you can offer!!!

This topic has been closed for replies.

1 reply

Nesa Nurani
Community Expert
Community Expert
May 16, 2024

Try this as custom calculation script of "Overall Rating" field:

var avg = 0;
var score = 0;

for(var i=1; i<=16; i++){
var f = Number(this.getField("Rating"+i).valueAsString);
score += f;}
avg = score/16;

if(avg <= 1.5)
 event.value = "Below Expectations";
else if (avg <= 2.5)
 event.value = "Not Meeting Expectations";
else if (avg <= 3.5)
 event.value = "Meeting Expectations";
else
 event.value = "Exceeding Expectations";

In the dropdown fields under 'Options' tab, check 'Commit selected value immediately',

you can check this option on all dropdown fields at once by selecting them all, then right click on them and go to properties ⇾ options tab, instead of going one field at a time.