Is it somehow possible to skip empty fields?

I'm trying to get the average value of a specific field, but on some nodes this field is empty.
Currently it's treated as 0 (zero) and this screws up my results.

Comments

oadaeh’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Assigned: Unassigned » oadaeh
Category: support » feature
Status: Active » Needs review
StatusFileSize
new2.16 KB

I've attached a patch that will add a second average field, so you can choose 'Average (include empty values)' or 'Average (exclude empty values)'.

The first one operates exactly as Average did before.

The second one will exclude empty fields (''), but include fields that have zeros ('0' or '0.00'), as that should be desired.

This patch also includes the patch from #1739798: Totalling fails for math expressions using comma as decimal separator.

oadaeh’s picture

FYI, after applying the patch, you need to clear your cache for the summary to show up in the view. It will show up in the Views UI just fine w/o clearing the cache, but not in the views themselves.

oadaeh’s picture

Status: Needs review » Fixed

This has been committed to the 7.x-1.x branch, here: http://drupalcode.org/project/views_summarize.git/commit/d75e322

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.