5

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.

6

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.

  1. For User Name - click on Aggregation settings and select "Group Results together".
  2. For Payment Value - click on Aggregation settings and select Aggregation type as SUM.

Check List

  1. 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.
  2. 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.
1
  • 5
    #1 on your checklist fixed this issue for me!
    – pjskeptic
    May 15 '13 at 0:21
3

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

1
  • 2016: aggregation works better now and Views Calc has a stable Drupal 7 version
    – AdamS
    Sep 28 '16 at 10:53
1

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.

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.