Closed (fixed)
Project:
Views Calc
Version:
7.x-1.0
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
28 Mar 2009 at 15:16 UTC
Updated:
1 Mar 2014 at 12:10 UTC
Jump to comment: Most recent
I have:
- latest released (not dev) versions on Drupal 6 as of 3/28/09
- cck field with an integer value on node type A
- a nid argument to limit the nodes to related nodes of type A
- view with style Views Calc Table that properly shows a table with the nodes,
but
- on the view edit page, adding an argument and clicking preview does not show the sum line
- visiting a node with the view shows the sum line, but no sums.
I have fiddled around trying every different combination. Further, I have looked through all the issues, but am stuck.
Any help is appreciated.
Comments
Comment #1
karens commentedYou are using values from a relationship? That is not currently working. It's going to be tricky because I have to find the right table name to swap into the query. I'm spending some time on this today. Not sure if I'll find a fix right away.
Comment #2
karens commentedRenaming for clarity.
Comment #3
johnthomas00 commentedKaren,
Does this same issue also apply to calculation fields? I am trying to calculate a price per X on content type A. The price is a CCK field on content type A, but the number of X's is on content type B, which is a node reference in A.
I wish I knew enough to help these "referenced" problems along. If there is something I can do to help, please let me know.
Comment #4
johnthomas00 commentedDisregard #3
In case others end up here from a search, my solution was:
http://drupal.org/project/computed_field
That module allows field calculations across content types.
Comment #5
hlykos commentedsubsribing
Comment #6
jmary commentedAny progress regarding that in the dev version ?
Comment #7
aleagi commented+1 here!
It would be nice to have relationship calc working... Is there any chance to get this?
Comment #8
aaronbaumanbump
Comment #9
gthing commentedSubscribing.
Comment #10
gthing commented@johnthomas00 Could you explain your solution? Were you able to calculate fields in a view using that module?
Comment #11
gthing commentedOkay I have a workaround.
Using the views_customfield module, you can add a customfield to your view that can contain PHP. I first put the following code into the customfield and viewed it to find the string name I needed:
<?php print_r($data);?>One you have the string, just replace the above code with this in the customfield:
<?php echo $data->string_name; ?>I should note also that this didn't work unless I already had the relationship field pulled in above the customfield in the fields section of my view. Since I don't want it to display twice I just set the first instance to not display. I hope that makes sense. Here is a screenshot of the relevant section:
https://img.skitch.com/20110406-rp4peran187cnacqwsgg2b2799.jpg
Also, you need to be using views_customfield dev and install the patch from here: http://drupal.org/node/576264
I imagine a similar approach could be used to build in support for relationship fields out of the box. I think if you need more flexibility the views_customfield module could also entirely replace the functionality of views_calc.
Comment #12
Mokey commentedCan #11 be copied to the front page of this module? I find myself referring back to it regularly, both for the fix to the relationship issue, but also to remember how to use print_r($data) to find the field names (I am not a php programmer, so this is not obvious to me).
Comment #13
cgv commentedHi: I change line 207 (query_total) in views_calc_table.inc
from: $query_field = substr($field->field, 0, 3) == 'cid' ? $field->definition['calc'] : $field->table .'.'. $field->field;
to: $query_field = substr($field->field, 0, 3) == 'cid' ? $field->definition['calc'] : $field->table_alias .'.'. $field->field;
then sum works fine. I change in a view with two relationship nested and works fine, but it needs more tests to check if this is the right solution.
I didn't test for query_sub_total yet.
Regards
Comment #14
raghugs commentedThank you so much for your findings.
I did the changes you suggested and now the results are coming perfectly in both total and sub-total.
Comment #15
Sinan Erdem commentedCan we somehow apply this to D7 version?
Comment #16
fboulanger+1 for a Drupal 7 solution, thanks...
Comment #17
senzaesclusiva commented#13
View Calc 6.1 dev
Applied #13 patch but Doesn't works on D 6.28 and Views 6.x-3.0
Comment #18
senzaesclusiva commented#13
Now applied patch to View Calc 6.x-1.3 on D 6.28 and Views 6.x-3.0.
Works fine now, thanks
Comment #19
doublejosh commentedStill broken for field handlers.
Comment #20
brylie commentedI set this to be a feature request, as it is not really a bug per se. It would be a valuable feature.
As a project manager
I would like to calculate time spent on activities for projects
given that there is a project content type
and that there is an activity content type
and the activity content type has a decimal field called 'hours'
and that the activity content type has a relation field called 'related project'
Scenario: Creating a view with total hours
A new view is created showing a table activities related to a project
The activities table has a column for the decimal field 'hours'
The views calc style is able to perform various calculations on the hours results for the view query
Note: the view query should contain sufficient details regarding the database fields involved in the relationship
Here is an example page:
http://growhost.org/project/akgillespie
Comment #21
skdrupal88Test please my patch, perhaps it will fix the problem.
https://drupal.org/comment/8342915#comment-8342915
Comment #22
karens commentedLatest dev version should be working. The zip file does not seem to be getting updated but the git checkout should work right.
Comment #23
karens commented