The aggregation setting (the emmajane episode!)

This screencast shows how to use the "aggregation" setting, lurking in the advanced options in Views. The aggregation setting makes Views return not one row per item in the database, but one row per aggregation group. Perhaps more importantly, it also makes it possible to count the number of items baked into each row, or sum them up, or calculate their average, or count the number of unique items, or…

To use aggregation in a sensible way:

  1. Turn on the aggregation setting (duh!)
  2. Make sure you don't have any sorting or filtering on data that is unique per database entry (such as sorting by post date)
  3. Add the fields you want to display as unique groups – such as content type (if that's a relevant category), author, shirt size, etc. Use the 'group similar results together' aggregation mode.
  4. Add the fields you want to do calculations on – sums, averages, counts, etc. Set the appropriate aggregation mode.


Note 1: the aggregation settings will appear for all handlers – not just the field settings. At least for relationships, though, the aggregation doesn't seem to do anything (which for a database perspective makes sense).
Note 2: If Views doesn't return the things you expect it to, it might be a good idea to turn on the display of SQL query. That's done in the Views settings (admin/structure/views/settings).

Feel free to praise Island Usurper and emmajane on IRC or They rock.

Additional Resources: 


Elijah Lynn (not verified)

Errors showing to anonymous -->

Notice: Undefined index: base path in EntityTranslationDefaultHandler->__construct() (line 193 of /mnt/www/nodeone-site-release-2/web/profiles/no_enterprise/modules/contrib/entity_translation/includes/
Notice: Undefined index: path wildcard in EntityTranslationDefaultHandler->getPathInstance() (line 499 of /mnt/www/nodeone-site-release-2/web/profiles/no_enterprise/modules/contrib/entity_translation/includes/

Kasia (not verified)

Hi! Great screencast! It saved me a lot of time and allowed to finally understand how aggregation works and that it's completely different thing than grouping.

zJoriz (not verified)

Wow, thanks tons! Views is the best, but like you said, kinda difficult to wrap your brains around at times. Seeing it demonstrated is very insightful.

http://xhtautop... (not verified)

Also, if the company offers services that include heavy equipment such as dump trucks and other types of
heavy trucks, it is important to know when and
where chains can be used. For this reason, accounting may be one of the best jobs in a recession.
Even if an original warranty is no long valid, many reputable used truck dealers offer their own drive-away
warranties as well as the option to purchase extended warranties.

Jory (not verified)

Hi, I'm having a problem with aggregation and am hoping you could help me.

I'm making a google maps of all users on a website and would like to combine all users that have the same lon/lat coördinates. The problem is that aggregation can combine the coördinates but because the names are different the output are still separete.

Short example of my current results:

/* ROW 1 */
52.3385, 5.62328
- Jory Hogeveen

/* ROW 2 */
52.3385, 5.62328
- Test name

/* ROW 3 */
51.7571, 5.91219
- Test name two

What I would like to have:

/* ROW 1 */
52.3385, 5.62328
- Jory Hogeveen
- Test name

/* ROW 2 */
51.7571, 5.91219
- Test name two

Could you please help me with this? You can reach me on

Thanks! Jory

Joe (not verified)

Thanks! This visual helped me figure out Views Aggregation for my own project. Like you said, the description associated with the feature isn't very clear.

Leave a comment