PDF Editing Issues

Calculate Average Excluding N/A in PDF Forms (Acrobat)

Algirdas JasaitisAlgirdas Jasaitis Nov 2, 2026 869 views

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.

How to Calculate an Average Excluding N/A and N/O in Acrobat PDF Forms
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.
Before you start

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.

Solution 1Recommended

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.

1
Enter Form Preparation Mode

Open your PDF in Adobe Acrobat and navigate to Tools > Prepare Form to reveal all interactive form fields.

2
Open Result Field Properties

Right-click on the field where you want the average to appear (e.g., 'Overall Rubric Score') and select 'Properties'.

3
Set Calculation Type

Go to the 'Calculate' tab in the Properties window, choose the 'Custom calculation script' radio button, and click the 'Edit' button.

4
Insert the JavaScript Code

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 : '';

5
Customize Field Names

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.

Use a Custom JavaScript Calculation Script
Zero Values Handled Correctly: This specific script treats the number '0' as a valid numeric value, meaning it will correctly factor into the total average without being ignored like the text strings.

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. 1. Open Your PDF Form: Launch WPS Office and open your interactive PDF document using the WPS PDF tool.
  2. 2. Fill Out Data: Click directly into the form fields to input your data; calculations embedded in the PDF will run seamlessly.
  3. 3. Save and Export: Once completed, use the Save icon to preserve your data or export the filled form to share with others.
Easily view, fill, and manage interactive PDF formsFully compatible with standard PDF formats and Adobe Acrobat formsLightweight and fast PDF viewer with advanced editing tools built-inCross-platform support allowing form management on Windows, Mac, and mobile
microsoft office alternative - wps office

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.