I have a field called payment_value for different customers i need to calculate the sum of payments for each customer , i can see ""use aggregation =Yes" at the view page but i dont know how to implement this option . thanks a lot.
3 Answers
I am not sure if you have already found the answer. I found this question from Google, so I am answering this so that somebody else might benefit.
When you are using Aggregation = Yes, remember one rule of thumb : All the fields that you are selecting must either use GROUP BY that field or some aggregation function on that field.
In your case you have two fields, User Name and Payment value. Once you enable the Aggregation, you will find Aggregation settings
beside your fields in Fields, Filter and Sort groups.
- For User Name - click on
Aggregation settings
and select "Group Results together". - For Payment Value - click on
Aggregation settings
and select Aggregation type as SUM.
Check List
- In-spite of the above if your view is not using, then the culprits are sort and filters. Be careful about them. Removing them and adding them back one by one may be a easier solution.
- Remember that sorting is not necessary as GROUP BY does default sorting of groups. And more over if you add a sort it might add an additional GROUP BY, if your settings are not right.
-
6
Aggregation is currently broken in Views 3. See all of the issues
Try View Calc module. Currently the is only a Drupal 6 version. I see from your comment you are looking for a Drupal 7 solution see the status here
-
2016: aggregation works better now and Views Calc has a stable Drupal 7 version– AdamSSep 28, 2016 at 10:53
If you're looking for one line per customer with the sum of their payments, then Views Group By is the module you're looking for. The release version only supports COUNT, the dev version supports SUM, MIN, MAX and AVG, too.