Troubleshooting Issues with Calculation Results

Summary

When the calculation result stored in the entry differs from the result displayed on the front-end, that indicates that one or more field values referenced in the formula were not available.

How calculations work is that the value you see on screen is not included in the submission. For security reasons, the calculation is rerun during submission using the field values saved in the entry. If a field hasn’t been saved yet, then its value isn’t available to the calculation. The most common cause of this issue is if fields are in the wrong order; a calculation field must always be located after all the fields referenced in the formula.

Note: The Total field type is always the last to be saved, so its value is not available for use in calculations.

Another cause is if the field used in the formula has a conditional logic rule based on a choice based field such as checkbox, radio buttons, or multi-select and the choice includes special characters or HTML.

Solutions

The solution to the total field not being available is to use a Number field with a subtotal calculation. Refer to the GravityWiz Subtotal Merge Tag (for Calculations) article for more information.

You can test with logging enabled to determine which field value wasn’t available when the calculation was rerun. See Logging and Debugging for details on how to do so.

Example Logging Statements

  • DEBUG –> GFFormsModel::save_input(): Queued field operation: Calculated Subtotal ([field label])(#[field id] – [field type]).
  • DEBUG –> GFCommon::get_calculation_value(): No value or non-numeric value available for field #[field id]. Returning zero instead.
  • DEBUG –> GFCommon::calculate(): No result or non-numeric result. Returning zero instead.