Calculate Average Excluding N/A Radio Buttons in PDF Forms
Question details
The user needs to calculate the average score from a set of radio buttons in a PDF form, ensuring that any "N/A" selections are ignored rather than counted as zero.

- Product
- Adobe Acrobat / PDF Forms
- Device & OS
- not provided
- Scenario
- Scoring call-monitoring categories using a 1-4 scale and an N/A option in a fillable PDF form.
- Observed behavior
- Built-in average functions or Simplified Field Notations count the "N/A" options as zeros, artificially lowering and skewing the final average score.
Ensure your PDF editing software supports custom JavaScript execution for form fields, as standard built-in formula options cannot conditionally exclude values. Keep a list of the exact field names of your radio buttons handy before scripting.
Use a Custom JavaScript Calculation Script
A custom JavaScript loop allows you to conditionally check each radio button and exclude the "N/A" or "Off" values before computing the final average.
Because Simplified Field Notation does not support conditional logic (like IF/THEN statements), it cannot selectively ignore specific values. By using custom JavaScript, you can parse an array of field values, discard the "N/A" selections, and accurately calculate the average of only the scored fields.
Open your PDF form in Adobe Acrobat Pro or a compatible advanced PDF editor, and activate the 'Prepare Form' or form editing mode.
Right-click the text field where you want the final average to be displayed and select 'Properties' from the context menu.
Navigate to the 'Calculate' tab in the Properties dialog box and select the 'Custom calculation script' option.
Click 'Edit' and enter a JavaScript code that creates an array of your radio button field names. Use a loop to iterate through each field, retrieving its current value.
Inside the loop, write an IF condition to skip fields where the value is 'Off' or 'N/A'. Convert the remaining valid values to numbers, add them to a total sum, and increment a counter for the number of valid fields.
Divide the total sum by the valid field counter. Add a fallback condition: if the valid field counter is zero (meaning all selected fields were N/A), output a blank string to prevent a divide-by-zero error.

Manage and Fill PDF Forms with WPS Office
WPS PDF provides a comprehensive set of tools to read, edit, fill, and sign PDF forms seamlessly. Whether you are dealing with interactive radio buttons, checkboxes, or text fields, WPS Office offers a lightweight, highly compatible, and user-friendly experience for handling complex PDF documents.
- 1. Install WPS Office: Download and install the free WPS Office suite on your computer or mobile device.
- 2. Open Your PDF Form: Launch WPS PDF and open the interactive PDF form you need to fill or review.
- 3. Highlight Fillable Fields: Click on the 'Form' or 'Fill & Sign' tab. WPS PDF will automatically recognize and highlight fillable areas, including radio buttons.
- 4. Input Data Seamlessly: Click on the radio buttons to select your scores and enter text. WPS PDF will process built-in standard form calculations automatically.

Frequently Asked Questions
Why doesn't the standard 'Average' setting work for N/A fields?
The built-in 'Field is the Average of the following fields' setting in PDF editors treats unselected options or text-based values like 'N/A' as zeros. This adds to the denominator and artificially lowers the final calculated average.
Can I use Simplified Field Notation to exclude N/A?
No. Simplified Field Notation only supports basic arithmetic operations. It does not support the conditional statements (such as IF/ELSE) required to selectively ignore specific text values or unselected buttons.
What happens in JavaScript if all radio buttons are selected as N/A?
If your custom script does not account for this scenario, dividing the sum by zero valid fields will result in a JavaScript error or 'NaN' (Not a Number) displaying in the field. Your script should explicitly check if the valid field count is zero and return a blank value instead.




