I need this feature and see this Q&A, I try it but not getting desire result, keeping on my search and I found Views Aggregator Plus . this is exactly I need and good solution for future guys that search for this feature.
As the Views and Views Calc modules rely on the database to perform
aggregation, you only have limited options at your disposal. As the
great Merlin himself said: "You can't aggregate a PHP expression in
the database. :/ ". That's where Views Aggregator Plus comes in. In
addition to what Views and Views Calc do, this module:
enumerates group members
produces tallies, i.e. textual histograms
aggregates on Views PHP code-snippet evalutations
can filter out result rows on regexp patterns
gives you sorting on Views' Math expressions
can process Webform submissions
lets you add your own custom aggregation functions
... and it puts summary statistics at the bottom of your aggregated
table as well! Recap: what is aggregation again?
In the context of Views tables and this module, aggregation is the
process of grouping and compressing result rows on the identical
values of one column, while at the same time applying "summary"
(aggregation) functions on other columns. For example, you can group
the result set on a taxonomy term, so that all rows sharing the same
value of the taxonomy column are represented as single rows, with
aggregation functions like COUNT, ENUMERATE or SUM applied to the
remaining columns. Example
Say the original View based on raw database results looks like below.
Industry Company Name Turnover IT AquiB $ 25,000,000 Clothing
Cenneton $ 99,000,000 Food Heiny $ 66,000,000 IT PreviousBest
$ 5,000,000 Food McRonalds $500,000,000
Then with the grouping taking place on, say Industry, and aggregation
functions TALLY, ENUMERATE and SUM applied on Industry, Company Name
and Turnover respectively, the final result with a descending sort on
the last column will display like below. Note that the module
identified three groups. It also added a totals row, Views Calc style.
Industry Companies Turnover Food (2) Heiny, McRonalds $566,000,000
Clothing (1) Cenneton $ 99,000,000 IT (2) AcquiB, PreviousBest $
30,000,000 Totals 5 $695,000,000
But that's just the beginning. Remember, you can aggregate on Views
PHP expressions, so the possibilities are endless! See the README for
examples using PHP code snippets.
For the "totals" row you may use the module's Math expression column
aggregation function and replacement tokens to calculate a field as,
say, the product of two preceding fields.