I have a content type: classroom

I have another content type: lesson

Lesson nodes have an entity reference field (field_classroom) that reference classrooms.

I want to create a view that outputs a table like this:

Classroom Number of lessons
Leicester Square 5
Piccadilly Circus 8
London Bridge 0

So, there are five lesson nodes that reference the "Leicester Square" classroom (all the classrooms are named after places in London), 8 that reference the classroom named Piccadilly Circus, and 0 lesson nodes referencing London Bridge.

Is there a way to achieve this in views?

I'm playing around with relationships and aggregation but I can't get it to work.

1 Answer 1


Silly mistake. I had the relationship the wrong way round. Now it's working perfectly. These are the steps:

1.) Create a relationship: Content using field_classroom (not content referenced from field_classroom)

2.) Enable aggregation

3.) Add a field: field_classroom

4.) Use the relationship

5.) Set aggregation on the field to COUNT

And it works!

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.