Views aggregation counts empty values in Webform Submissions

Created on 31 January 2023, almost 2 years ago

Problem/Motivation

Drupal views offer the option to use aggregation, to show COUNT, AVERAGE, SUM etc of fields.

This feature does not work well with views that display Webform Submissions, since empty values are counted.

Steps to reproduce

  1. Create a webform with a non-required field of type "Radios", with two options with values "1" and "2"
  2. Create three submissions for this webform: one where you leave the field empty, one where you select the option with value 1, one where you select the option with value 2.
  3. Create a view that shows submissions for this webform. Set "Use aggregation" for the view to "Yes".
  4. Show the radio field you created, select "AVERAGE" for aggregation settings.
  5. The average will be 1 ((1 + 2 + 0) / 3) - the average should be 1.5 ((1 + 2) / 2)
  6. When you set the aggregation settings for the field to "COUNT" you will see it counts 3 values, even though for one submission the value does not exist
  7. This is not how views aggregation should behave, and not how it behaves in other views, eg for content. Empty values should not be counted at all.

Proposed resolution

Stop Webform Views from including empty values from Webform Submissions when using views aggregation.

🐛 Bug report
Status

Active

Component

Code

Created by

🇦🇹Austria stemiwe

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024