Closed (fixed)
Project:
Views Calc
Version:
5.x-1.0
Component:
Documentation
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
28 Apr 2006 at 10:55 UTC
Updated:
6 Aug 2008 at 07:52 UTC
If a field created by CCK or another module contains numerical data, would it be useful for the Views module to be able to sum/multiply/perform arbitrary math on those fields? This would allow spreadsheet-like functionality. So if a View creates a list of nodes containing numerical data (i.e. users with an age field, or financial information such as subscriptions), those fields could be summed and the resulting output displayed.
Comments
Comment #1
talltim commentedAny thoughts on this? Having thought about this some more, I think that it would apply best in a view set as a table. The table would present a list of relevant data, filtered as required, and any numerical fields in the table could be summed/multiplied etc. as required.
Comment #2
karens commentedI like this idea, too, and could use a feature like this. However, it would probably be pretty hard to implement and I'm not sure exactly how it could be done.
Comment #3
alanburke commentedI Posted something about this is the Event module
http://drupal.org/node/49157#comment-97221
[copied from there]
Could it be ammended to allow showing events for the next X days, or X months, something like that.
The Filters on Start time [all my events only have a start time being sporting events], only allow comparison based just on current time.
If I could filter something like:
Start Time is greater than current time
AND
Start time, is less than, [current time + 30 days]
That would be great, always showing upcoming events for 30 days.
[end copied]
The ability to perform simple mathematical caluclations would be very useful
Alan
Comment #4
karens commentedI figured out a way to add calculations to my views table and have put a views_calc module in my sandbox at http://cvs.drupal.org/viewcvs/drupal/contributions/sandbox/karens/views_.... Download and install the module, go to the settings page and select the view you want to perform calculations on, the fields you want to calculate on, and whether you want to SUM, COUNT, or AVERAGE the fields, and save those settings. Then go to the view and you should see new rows and/or columns added with the totals you asked for.
Obviously this is very alpha stage, but it does seem to work. No ability to do things like add some number of days to a date, but things like that might be later enhancements. Please let me know if it works for you.
Comment #5
merlinofchaos commentedNifty stuff. Very interesting.
Comment #6
moshe weitzman commentedfrom the description, this looks extremely useful. i hope it matures past the sandbox soon
Comment #7
karens commentedI have done some tweaking and adjusting and I think it is working as advertised at this point. The module is in my sandbox at http://cvs.drupal.org/viewcvs/drupal/contributions/sandbox/karens/. You need the views_calc module and the views_calc.css. I have it on a production site now and it seems to be working fine, but it would be good if others could test it. Alanburke emailed me that he was using and it was meeting his needs, but I have made some changes since then (mostly minor ones).
Comment #8
talltim commentedSee bug report: http://drupal.org/node/63858
I think this is views_calc related: the problem occurs when I create a view with no associated calculation, but goes away when I create the relevant calculation.
Comment #9
karens commentedI think this is now fixed. It was related to my effort to theme the results, and the whole process for themeing has been changed to take advantage of a new plugin in the views module. Let me know if this fixes things for you.
Comment #10
talltim commentedThat fix worked fine (I followed up and closed the other issue I started but not this one which was a bit of a cross-post, mea culpa etc.).
Another question though: I have a view with two columns of numerical data which both have calculations performed on them via views_calc. For example, one could be "Apples bought this month" and the other could be "Apples eaten this month". If I want to calculate the total growth of my store of apples, how can I display the results of one column added, subtracted, etc. to the other column's result?
The reason I'm thinking of doing it this way is because I don't think it's possible to show the values of different fields in a single column. Otherwise I'd create two separate node types, one being "apple intake" and another being "apple consumption" and do the sum in a single column. But I can't do that, which makes sense in this context anyway.
I'm also expecting to run into the "grand totals" problem (described in the module's code comments) at some point when I record more than 99 transactions, but I guess that's already on the TODO list.
Comment #11
karens commentedI was going to say you can add the columns, but then I realized you probably mean you want totals for the added columns, which the current version of views_calc does not do. Yes, that probably would be a nice to add feature. I just wanted to get something basic that was working reliably as a starting point.
Comment #12
karens commentedViews Calc has been set up as a separate project now at http://drupal.org/node/67344.
Comment #13
merlinofchaos commentedComment #14
(not verified) commentedComment #15
markrei commentedhow can i used this module "views_calc" it doesn't work for me, any suggestions you can give i need to sum different fields..
thanks in advance
Comment #16
alanburke commentedPlease open a seperate support request for Views Calc. [rather than opening a closed issue].
You'll need to give a few more details of what you're trying to do,
and what you've tried so far, and how it worked or didn't work.
Regards
Alan