0

I need to count the number of entries made to a field in all nodes combined together.

I tried toggling aggregation to 'yes' and aggregation type to 'COUNT as distinct'. But at that time I'm getting count for each node separately. But What I really need is a single line output saying this much of entries made to this field for the whole nodes combined together.

The after that I will be able to filter it by 'id from logged in user' or 'date created'.

2

There is a module to assist with that: Views Field

Allows field tables to be used as base tables with Views.

After you installed the module you need to visit the field setting on any content type that includes the field. Tick Expose as base table, then select all the columns to expose excluding revision_id.

Next create a view and at admin/structure/views/addat Show listbox you select the Field base table. This will now create a view on the field in question's base table.

Your view settings should have these settings:

  • Use aggregation: Yes
  • Fields: Entity Type (The entity type this data is attached to) with Aggregation setting Count.

You can now add Relationship: Field tables: Field XXX => Node to get access to the nodes the fields are attached to and from there author etc.

ALTERNATIVE

Create a View of Content (ie nodes) showing fields. Set Aggregation to Yes. Remove sort Criteria, filter criteria and Pager. Add your field's delta (Delta - Appears in: node:xxx.) to the View fields with aggregation set to COUNT.

  • That was exactly what I needed. Prompt answer I really appreciate it Thanks. – Lalas Muathasim Jun 25 '16 at 15:44
  • Hi Reynolds i have came up with an another problem as in the form a bug you can visit the queue and comment drupal.org/node/2755751 – Lalas Muathasim Jun 26 '16 at 17:12
  • Check my updated answer. Arguably simpler than the original answer. – J. Reynolds Jun 27 '16 at 14:23
  • Thanks for the updated post that worked like a charm. The field to be counted was a date field and if the number of values is '1' then field:delta is not appearing in the views-add field list, is this normal? Anyway i can make the number of values unlimited and hide the add another button with css. – Lalas Muathasim Jun 28 '16 at 4:22

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.