Count how many times a node is referenced 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 &quot;Leicester Square&quot; 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.
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!