diff --git a/forms/qae_form_builder/matrix_question.rb b/forms/qae_form_builder/matrix_question.rb index a400b1fc55..f168ba0158 100644 --- a/forms/qae_form_builder/matrix_question.rb +++ b/forms/qae_form_builder/matrix_question.rb @@ -101,6 +101,7 @@ def calculate_proportion(question_key, answers, x_heading, y_heading) else disadvantaged = answers["#{question_key}_#{x_heading}_total_disadvantaged"].to_f end + disadvantaged ||= 0 total = answers["#{question_key}_#{x_heading}_calculated_total"].to_f proportion = (disadvantaged.to_f / total * 100).round(2) answers["#{question_key}_#{x_heading}_calculated_proportion"] = proportion