Changing aggregation type in Views does not apply until field is deleted and re-added

Created on 12 July 2025, about 22 hours ago

Problem/Motivation

In Views, changing the aggregation type of a field (e.g., from Count to Sum or Average) does not take effect after saving. The View continues to apply the old aggregation type, even after clearing caches. The UI appears to save the change, but the output doesn't reflect it.

Steps to reproduce

1. Create a View and enable `Use aggregation` under the "Advanced" section.
2. Add a numeric field (e.g., node ID or a custom integer field).
3. Set its aggregation type to "Count" and save the View.
4. Now go back and try to change the aggregation type to "Sum", "Average", or any other.
5. Save the View and clear all caches.
6. Reload the View output.

Proposed resolution

The only way to make the new aggregation type work is to:
- Delete the field from the View entirely.
- Set `Use aggregation` to **No** and save the View.
- Re-enable `Use aggregation`, then re-add the field and set the desired aggregation type.
This resets the internal state and makes the new aggregation type apply correctly.

- Drupal 9.5.x
- Drupal 10.5.x

Remaining tasks

When an aggregation type is changed and the View is saved, the new aggregation should immediately reflect in the output, without needing to delete and reconfigure the field.

API changes

This appears to be a bug in the Views UI. The field’s aggregation type doesn’t update properly unless the field is deleted and re-added, which is not ideal for user experience.

🐛 Bug report
Status

Active

Version

10.5

Component

views.module

Created by

🇮🇳India Neelanjana Das

Live updates comments and jobs are added and updated live.
  • views

    Involves, uses, or integrates with views. In Drupal 8 core, use the “VDC” tag instead.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024