Last updated 8 July 2012. Created on 8 July 2012.
Edited by jordojuice. Log in to edit this page.

There are a couple of options for grouping view results using Views Chart Tools. Sure, Views 3 has aggregation options built in. However, Google Chart Tools has aggregation functions as well, with some additional features to boot. Let's take a look at using grouping and aggregation in Views Chart Tools 1.x.


Create a chart outlining the total number of nodes created in a given quarter. While this may be an unrealistic example, using the aggregation and modification functions demonstrated in this example can be used for much more useful purposes. For example, a line graph demonstrating the average number of products sold per day in a given quarter. I just don't have the time or will to create and sell a few thousand products, so we'll stick with auto-generated content.

Grouping results

First, let's take a look at our example view configuration.
View configuration
Here we have the Google Charts Dashboard style enabled along with a table chart and pie chart. In addition, we have two fields - Content: Post date and Content: Nid.
First, since our end goal is to group results by quarter, we want to group the Content: Post date column.

Step 1: Google Charts Dashboard settings

Click on the Google Charts Dashboard style settings link to view the dashboard configuration page. Here we see our dashboard's data table structure. This view is intended to help users visualize the data being input into charts and format that data appropriately.
Data table overview

Step 2: Set the data types

As you'll notice, our Content: Post date column is marked as a string by default. While it is possible to render the date as a string, it would not be formatted properly, so we want to mark it a date type column. Note also that the Nid column is a number, so we can set its data type to number if we want, but remember that we will be aggregating (counting) the nodes that were created later anyways - and returning a number - so that makes the data type here irrelevant.
Setting the field type
You'll notice that setting the column as date caused the roles to disappear. This is because column roles require specific data types, but more on roles in another tutorial.

Step 3: Group the results

Next, we want to enable grouping for our Post date column. Grouping results will match all rows with the same value in this column and allow us to aggregate additional fields.
Enabling grouping

Step 4: Modify the grouped data

Now that we've grouped the data table by Post date, you'll notice that a new field appeared. This is an optional modifier function that we can apply to the grouped column. In our case, we want to group by Quarter, so we can go ahead and select that option. (Note that Views Chart Tools currently only has modifier functions for Date and Date/time type columns - please submit a feature request for specific additional modifier or aggregation functions).
Modifier functions

Step 5: Aggregate additional columns

Finally, when grouping a data table all columns that are not grouped must be aggregated. In our case we want to count the total number of nodes created for each quarter, so we select the count aggregation function. Note that we do not aggregate the Post date column.
Aggregation function

The final product

Finally, we should have a style options form that looks something like this:
Completed configuration
Now we can apply the changes and view our charts.


This table uses formatting for the aggregated nid field. Formatting options are available on the same style settings form by clicking the format link next to a field. This particular table uses the Bar format which demonstrates while values are above or below a certain level.

Pie chart

Pie chart

Line chart

Here's an additional line chart that was later added to the same view.
Line chart

Looking for support? Visit the forums, or join #drupal-support in IRC.


t.eshqair’s picture

Iam new drupal developer I have a task to make a page of different charts which are change dynamically according to some filters ( date , category , country .. etc) .

I could make the separated charts using google chart dashboard but I need to mix them in the same page with the same filter !! please help

jason.fisher’s picture

If you put multiple views on the same page, and give them the same filter option keys, they will all take the shared filter values. i.e. turn them all to 'exposed filters as block', then display one of the blocks on the page with multiple views. Now all should update to reflect the shared filters when you search.