1

I have a content type - lets say favorite color - where you can choose blue, green, red ....

  • One node of favorite color has red
  • Another node of favorite color has green
  • Another node of favorite color has again red

and do so on

I would like to show in views3.7 the name of the color and how often it occurs:

  • red: 10
  • green: 6
  • blue: 3

How do I do this? I think its aggregation but I cant display the number of each result...

1
  • I'm assuming that the 'favorite color' is a tag or vocabulary term? Commented Jul 8, 2013 at 18:51

1 Answer 1

3

If what you're trying to show is the number of nodes tagged with a certain term (I'm assuming that color field is a term, not a select text field), then the following Drupalwoo tutorial has detailed step-by-step instructions on creating a view that shows the number of nodes per term.

Here are the basics - just without the screenshots.

  1. Your view should be setup to display taxonomy terms, not nodes.
  2. Add a relationship that is 'Taxonomy term: Content using <term name>', in your case the term name will be something like 'Color'
  3. Configure the relationship to be required or not: depending on whether you want to show colors even if there are no nodes tagged with that color
  4. Select to use aggregation in the view's advanced settings
  5. Add a node field to this view that is excluded from the display, but is used to count the number of node instances under each term. I would select the 'Node: nid' field for this purpose. Make sure to use the relationship setup above
  6. Finally - select 'Count DISTINCT' as the type of aggregation for this field
  7. You'll probably want to style the output a little: in your example you want to use a colon between the term and the count, while in the blog's example above there are parentheses! Feel free to style however!

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.