I want to make a survey with Drupal, using Fivestar fields. So, I created a new content type called "survey" and added fields "field1, field2, field3, ..." The user can add content "survey" and the results of the voting are saved in nodes.

Now, I want show an average for all nodes with the content type "survey": Display the average of the individual fields of the survey. How can I do it?

2 Answers 2


Consider a table similar to this one:

enter image description here

The Views Calc module can be used to transform that table so that the calculations in the last rows (with Count, Sum and Max) get added to it. So that the table looks similar this:

enter image description here

By replacing the columns '# Fish', 'Weight' and 'Big Fish' in the example above with 'field1', 'field2' and 'field3' (as in the question), and by asking for the 'average' to be added (instead of Count, Sum or Max), it should answer the question I think, no?

To ask for the 'average', just select it from the selection list as shown in this screenshot (instead of the ones selected in that screenshot):

enter image description here

For more details (step-by-step instructions), refer to the community documentation about the Views Calc module.


Look at using Views and Views Calc. Here are some more details about these modules (quotes included are from their project pages):

  • Views:

    You need Views if

    • You like the default front page view, but you find you want to sort it differently.
    • You like the default taxonomy/term view, but you find you want to sort it differently; for example, alphabetically.
    • You use /tracker, but you want to restrict it to posts of a certain type.
    • You like the idea of the 'article' module, but it doesn't display articles the way you like.
    • You want a way to display a block with the 5 most recent posts of some particular type.
    • You want to provide 'unread forum posts'.
    • You want a monthly archive similar to the typical Movable Type/Wordpress archives that displays a link to the in the form of "Month, YYYY (X)" where X is the number of posts that month, and displays them in a block. The links lead to a simple list of posts for that month.

    Views can do a lot more than that, but those are some of the obvious uses of Views.

  • Views Calc:

    ... adds simple calculations to a views table. Requires the Views module.

    You can SUM, AVERAGE, COUNT, MIN, MAX, or AVG selected columns. A plug in theme makes the view look more spreadsheet-like (right justifies numeric fields, shades calculated columns and rows, and underlines calculated rows).

    You can also create custom dynamic fields that can be used in any view using SQL snippets like CONCAT('field_first_name', ' ', 'field_last_name') or DATE_FORMAT(node.created, '%m/%%d/%Y'). The custom fields are set up in admin/settings/views_calc.

  • And how can I calculate the average? I must to use a sql function, but i dont know the tables Jun 5, 2014 at 0:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.