Calculate Average Excluding N/A in PDF Forms (Acrobat)
Question details
The user needs to calculate the average of multiple score fields in a PDF form while automatically excluding specific text values like N/A and N/O, but keeping zero as a valid numeric score.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form, such as a grading rubric, where certain criteria might not apply (N/A) and should not negatively impact the total average score.
- Observed behavior
- Standard average calculation functions in PDF forms fail or calculate incorrectly when non-numeric text values (like N/A or N/O) are entered in the score fields.
Ensure you have access to a PDF editing tool that supports custom JavaScript for form fields, and note down the exact names of all the score fields you intend to average.
Use a Custom JavaScript Calculation Script
Apply a custom JavaScript snippet to the target result field to filter out N/A and N/O entries while properly counting valid numbers and zeroes.
By default, built-in PDF average calculations may struggle with non-numeric text strings. Using a custom script ensures complete control over which values are counted towards the final denominator.
The script loops through your designated score fields, verifies they are not empty or marked as N/A or N/O, and ensures they are valid numbers before adding them to the total sum.
Open your PDF in Adobe Acrobat and navigate to Tools > Prepare Form to reveal all interactive form fields.
Right-click on the field where you want the average to appear (e.g., 'Overall Rubric Score') and select 'Properties'.
Go to the 'Calculate' tab in the Properties window, choose the 'Custom calculation script' radio button, and click the 'Edit' button.
Paste the following script into the editor: var names = ['Score1', 'Score2', 'Score3', 'Score4', 'Score5', 'Score6', 'Score7', 'Score8', 'Score9', 'Score10']; var total = 0; var count = 0; for (var i = 0; i < names.length; i++) { var v = this.getField(names[i]).valueAsString; if (v !== '' && v !== 'N/A' && v !== 'N/O' && !isNaN(Number(v))) { total += Number(v); count++; } } event.value = count ? total / count : '';
Replace the generic 'Score1', 'Score2', etc., in the array with the exact names of the fields in your specific PDF document. Click OK, then close the properties window and test your form.

Edit and Manage Interactive PDF Forms with WPS Office
WPS Office includes a robust PDF editor that allows you to effortlessly fill, manage, and print interactive PDF forms. It provides a lightweight, highly compatible environment for handling advanced PDF documents without the heavy subscription costs.
- 1. Open Your PDF Form: Launch WPS Office and open your interactive PDF document using the WPS PDF tool.
- 2. Fill Out Data: Click directly into the form fields to input your data; calculations embedded in the PDF will run seamlessly.
- 3. Save and Export: Once completed, use the Save icon to preserve your data or export the filled form to share with others.

Frequently Asked Questions
Why does the standard average function fail when a field says N/A?
Standard built-in average calculations in PDF software often treat non-numeric text strings as errors or zero values. This incorrectly increases the denominator of the average, negatively skewing the final calculated score.
How do I find the exact field names in my PDF form to use in the script?
While in the 'Prepare Form' or form editing mode of your PDF software, the names of all interactive fields are typically displayed as labels directly over the fields on the document, or listed in a side panel.
Can I add more or fewer than 10 fields to this calculation script?
Yes. You simply need to modify the 'names' array within the JavaScript code to include the exact names of all your score fields, whether you have 3 fields or 30. The loop will automatically adjust to the number of items in the array.
Does this script ignore blank fields?
Yes, the script includes the condition 'v !== ""', which ensures that any completely blank score fields are skipped and not counted towards the denominator of the average.




