Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By TreyeDesigns on
I am using Drupal version 7.2 and have tried both Views 7.3 rcl and Views 7.3 dev versions. I am trying to group a custom CCK field of decimal numbers together and get the total SUM. All my outputs display an empty field.
My test on both versions include stripping down everything inside the view except for
User Aggregation: Yes
Content: Time (This is my CCK decimal number field)
In short I am just looking for a way to display the SUM of a column of field values in views. Any ideas, links to documentation, suggestions, or ideas would be great.
Comments
How you get the calculation
How you get the calculation done ? Using Views Calculations module?
If it was not successful, you could try Views PHP Filter module to create a custom php filter and count fields using php.
That module does not support tokens out of the box but there was 2-3 patches with different approaches to get tokens working.
What's new and changing in PHP 8
The Views Calc module sadly
The Views Calc module sadly does not work yet with Drupal 7 the way I would like it to. There are still errors with it. How would i use the Views PHP Filter Module to create custom php filter to count the fields?
I guess I just am not sure really where to start / what variables and objects to call and or use. If some one could correct me but I believe this is the logic. What would the variables and objects be to call the values from each field?
Use Aggregation On views
I have the same problem too , when just use "use aggregation= Yes" no columns appear excpet the title and all the fields diapears . and there is aggregation setting link under each section of the view design elements, I need to Calculate Sum and Count of some fields in the view , How this can be done ???
There is a patch about aggregation in the issues for views
There is a patch about aggregation in the issues for views.
#1194900: Missing values with aggregation sum, avg, min, max (patch included)
It is 20 days old, they will probably add it in the next version of views.
Until then you can patch the code yourself.
I personally did patch it manually as it was the first patch I ever applied and I don't have the additional software to do any other type of patching.
Recommended readings:
http://drupal.org/node/620014
http://drupal.org/node/534548
Thank you for the reply. I
Thank you for the reply.
I ended up just writing some custom PHP to do all the calculations I needed. I used a views php field and wrote my own outputting for the rest.
Hi, can you share your views
Hi, can you share your views php solution? I am looking for the same.
Thanks!
Same here, can you post your
Same here, can you post your solution with PHP Field?
I was able to accomplish this
I was able to accomplish this by adding an attachment view that shows up after the primary view and tweaking the display to only show the total.
-----------
hoZt.com
can you
tell me how you did this?
I know how to add an attachment - but the tweaking part I don't get.
I override the display of the
I override the display of the attached view and remove the group by columns from the display for example:
Primary view fields:
group by category
count(items)
sum(total)
Attached view fields:
count(items)
sum(total)
-----------
hoZt.com
Thanks
I think I finally got it working - If I'm correct you have to do a count on any item before you run function like sum. If anyone esle is needing help, this video should do it.
http://dev.nodeone.se/en/the-aggregation-setting-the-emmajane-episode
Actually to anyone reading
Actually to anyone reading this, you do not have to do a count first...but you do have to get the grouping correct.