6

I have created a view using aggregation which counts the number of nodes created of a certain content type. I want to be able to group these by month i.e. Jan - 10, Feb - 15, Mar, 20 and so on. At present it is just a count of all nodes created.

How do I do this with views? I've looked around and cant seem to find any information how to do this. Any help would be appreciated. thanks

3 Answers 3

7

I just figured it out:

  • Create a view for all nodes (filtered by type or status if necessary).
  • I use a table layout, enabled aggreation, added field "nid" with "Count distinct".
  • I then add a sort by "post date" with "monthly" granularity.

  • Then I added a "post date" field with custom format "M-Y". I select "min" instead of "group results together. That's important, otherwise it will not group the results by month

1

Look into using the "group by" function in views. You will need to add a date field such as "node: updated date" to use to group by (you can optionally exclude from display).

Then on this date field use custom date format eg just month (m) which will give you a range for that month and it will group any content from that month.

You can then change your aggregation function to count per group and display in the group header by updating the views-x.tpl.php file.

0

I think you need to use views_date_format_sql

1
  • the answer given by the question author if working well and doesn't need an extra module
    – izus
    Commented Dec 5, 2018 at 13:39

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.