1

Popular Drupal 7 modules such as Views Calc and Views aggregate plus are not available for Drupal 8, so I'm struggling with achieving the following :

Making the sum of a column (of one integer field of list of child nodes) per parent node, without any custom code. No matter what I do with the "Use Aggregation" feature , I keep on getting a list of the values of entities meeting my criteria and not the sum.

enter image description here enter image description here

2 Answers 2

2

Your current configuration is doing the SUM of all numbers in that field but per views row, so you'd see numbers added up within each node if you had a multivalue field.

To make it sum up across all results/nodes you need to remove the Sort criteria, that can throw aggregation off.


I don't think your second question is making sense, you want to make a reference to a value calculated within views?

Entityreference creates a list of entities, and the summed up value is not an entity, you can't reference it like that. You can create a Views block and show the summed up value on some content pages and wherever you need it. Is that what you're after?

9
  • Thanks for answering, I appreciate it. Regarding my second question. I need to check that the SUM remains below a treshold value, which is a field of the referenced entity. So I thought I would pull the Views sum to another field as an entity reference to the view...
    – user89568
    Nov 5, 2018 at 21:31
  • Referenced entity or the one doing the referencing? Anyway I don't think Entityreference will let you do that, it expects nodes to be selected. Maybe you can use Math Field but it still isn't clear where the comparison value is located.
    – prkos
    Nov 5, 2018 at 21:47
  • The entity referenced (Parent) in the entities I'm summing up (Children). The parent also holds the field with the treshold. In short, I would need to get that sum into a field of another entity. Thanks for suggesting Math Field. It woudn't solve this problem, but another issue if have, if only it would be available for Drupal 8.... :-(
    – user89568
    Nov 5, 2018 at 22:18
  • I see more clearly now, but this seems to be a wider issue than just sums in views. Maybe you can open a separate question and include all the relevant information, and what your goal is. Maybe Views isn't the way to go for you, maybe something else will turn up.
    – prkos
    Nov 5, 2018 at 22:31
  • I tried to remove the sort criteria, but that didn't have any effect. Issue remains...
    – user89568
    Nov 6, 2018 at 12:39
1

In my initial attempts, I tried to created a view on the child nodes to which I applied a contextual filter to limit the results to the parent node. That didn't work.

In the end, the SUM worked, when I switched things around, I created a view on the parent, and establised a relation with the child nodes (through an entity reference). When I summed up the field (of the child), it worked.

2
  • 1
    can you add print screen of your view..?
    – SakaSerbia
    May 1, 2019 at 19:22
  • This worked for me. My view of "Child" type with a relation to the parent would not sum a dollar amount field I have on the Child nodes. I recreated the view as a "Parent" type with a relation to the child nodes, and I was then able to aggregate/sum the dollar amount fields.
    – hockey2112
    Apr 7, 2021 at 23:46

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.