Views Crosstab

Owen Barton - November 2, 2009 - 07:58

This views style plugin lets you display views results as a crosstab - grouping rows by one field, columns by another, and using an aggregate function (count, sum etc) of a third field for the table data.

For example, this module will take a table view with linear output like:

User Content Type Node ID
Anita Blog 1
Anita Page 3
Barak Page 5
Jamila Blog 2
Jamila Blog 4
Jamila Page 6

And turn it into a crosstab that counts the number of each type of content for each author:

User Blog Page Total
Anita 1 1 2
Barak 1 1
Jamila 2 1 3

A default view "content type count by user" that does just this is included with this module.

Usage notes:

  • This is a new module, and has not yet been tested in a production setting - please treat as such!
  • It is possible to produce SQL errors with this module, especially with very complex views. A good understanding of SQL will help you understand and fix these.
  • This module is fairly likely to be incompatible when used in the same view as other views modules that extensively modify the views query, such as Views Group By.
  • This module has not been tested with Postgres yet, and is unlikely to work as is.

Related modules:

  • Views Group By - allows grouping an aggregation of fields (useful for lots of things!), but does not allow a crosstab of 2 fields against each other.
  • Views Calc - allows multiple column oriented aggregates to be added, as well as providing additional formatting control.

Releases

Official releasesDateSizeLinksStatus
6.x-1.0-alpha12009-Nov-029.9 KBRecommended for 6.xThis is currently the recommended release for 6.x.


 
 

Drupal is a registered trademark of Dries Buytaert.