Trouble calculating column sum on view with active views group_by (aggregation)

Created on 6 October 2021, over 2 years ago
Updated 13 December 2023, 7 months ago

Problem/Motivation

When using the regular "group_by" (views aggregation) option to calculate a sum (say of a numeric field), the views aggregator plus column sum function returns the sum of the first n (depending on the views result count) entity fields instead of the sum of the aggregated sums.

Steps to reproduce

Create a view of entities with a numeric field and a second field for grouping (in my case a taxonomy), set views aggregation (not the table aggregation!) to calculate the sum of the numeric field grouped by the other field. Set views aggregator plus table and set column operation to sum. Behold the wrong sum.

Proposed resolution

In getCellRaw, try to access $result_row values directly before doing additional steps.

πŸ› Bug report
Status

Postponed: needs info

Version

2.0

Component

Code

Created by

πŸ‡¦πŸ‡ΉAustria attisan Vienna

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • I second the need for this feature, because it greatly improves performance if grouping is done by the database. Patch #2 works well, is there any reason not to include this in the module, at least as a configurable option so existing views do not break?

Production build 0.69.0 2024