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

Ayesh’s picture

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.

TreyeDesigns’s picture

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?

<?php
$max = count($view->field_time)-1; 
$value = 0;
for ($timearray = 0; $timearray <= $max; $timearray++)	
	{
		$value + $views->field_time[$timearray]['value'] = $totalvalue;
		$totalvalue = $value; 
	}
print $totalvalue;
?>
arafat_aa’s picture

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 ???

icanko’s picture

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

TreyeDesigns’s picture

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.

Yuri’s picture

Hi, can you share your views php solution? I am looking for the same.
Thanks!

pokepasa’s picture

Same here, can you post your solution with PHP Field?

hoZt’s picture

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

Pun-1’s picture

tell me how you did this?

I know how to add an attachment - but the tweaking part I don't get.

hoZt’s picture

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

Pun-1’s picture

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

Pun-1’s picture

Actually to anyone reading this, you do not have to do a count first...but you do have to get the grouping correct.