I have a Organic Groups structure of:




I can use views to show all of the properties within an organisation by setting a contextual filters with OG membership: Group ID.

What I want to be able to do is count the number of open claims (a claim where a feild 'status' is set to 'open') within a property. For example:

Illustration of desired result

Is this possible using views? It seems to ask a lot of views as I guess I need a subquery or second query to get the claims of each property.

Each claim references a property in its group audience feild. Each property references an organisation in its group audience feild.



The end result of this will be a view using the organisation NID showing property with the number of claims.

ie. on an organisation's node, this would be the block.

Property 1 -  18 (open claims)

Property 2 -  13 (open claims)

Step 1: Grandchildren.

  1. Add your regular group ID contextual filter.
  2. Add the relationship, OG membership: Group Node from OG membership.
  3. Add it to your contextual filter as its relationship. This gives grandchildren.
  4. Filter out Property content type.
  5. Add property entity reference as a field.

You now have a all properties with all claims.

Step 2: Counting

  1. Try Views Aggregation in Advanced. It will probably cause an OG error.
  2. Instead, install Views Merge Rows. https://www.drupal.org/project/views_merge_rows
  3. It will add a new option under Advanced in your view.
  4. For title, Count merged unique values.
  5. For property entity ref field, Use values as a filter.

Now you should have something similar to my example above.

Step 3: Filtering to OPEN

  1. Add a relationship for that field. I just tried it with a taxonomy field but a Boolean should be similar.
  2. Add a filter, eg. (term from field_hello) Taxonomy term: Term ID (= 90210)

Adapt the filter to what you need or use the general idea to create your own solution.

  • @ Niall Murphy Thank you for the fast detailed response. I can add the contextual filter (OF membership: Group ID). When I add the relationship (OG membership: Group Node from OF membership) this doesn't show the grandchildren (claims). The view continues simply to show only the children (the properties) – Paul Trotter Mar 8 '16 at 14:51
  • Oh yeah, try adding the group node relationship to the group id contextual filter at the top of its settings. – Niall Murphy Mar 8 '16 at 15:01
  • Thanks. That reduces the results to only the claims, but now now properties are visible – Paul Trotter Mar 8 '16 at 15:49
  • I'm not sure I know what you mean by that.. You need to have the property entity reference field and the node title field and only for the claims content type. Then you can count the node titles. – Niall Murphy Mar 8 '16 at 15:53
  • That is great! Thanks. Then I was able to add in the extra feilds I needed for the property by setting their 'Relationship' to 'Group Node from OG membership' – Paul Trotter Mar 8 '16 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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