I am trying to create some simple reporting for the financial data to members of my nonprofit. We report weekly donations statistics to our members. I created a custom cck content type with three fields: (i) week of (date) (ii) actual income and (iii) income goals.
Then, I created a "Views Calc" Table to report the data. I then added two columns with calculations to the table with the Views Custom Field module to calculate the difference between the actual income and the goal and income as a percent of the goal.
When I go into the Views Calc user interface, I have the option to create a calculation on the these custom fields (see screenshot 1). However, when I hit save, nothing shows up (see screenshot 2). (It does not work regardless of the formatting of the "difference" column; that is not the problem)
Any ideas?
Preference 1: Calculate the Difference/Percent column from the SUM row Actual/Goal columns (then the percentage would be right).
Preference2: Calculate the SUM of the difference column (obviously, I couldn't create a correct percentage calculation).
| Comment | File | Size | Author |
|---|---|---|---|
| screenshot_2.jpg | 66.52 KB | keith_k | |
| screenshot_1.jpg | 113.61 KB | keith_k |
Comments
Comment #1
deggertsen commentedSame problem here. I got this error when trying to load the view where I was trying to calculate the total of a custom field:
This is the code I have to determine the value of the custom field:
Basically I'm calculating another value based off of another field. I'm wondering if Views Calc is trying to calculate the php rather than the resulting value?
I thought that it may also be that in this custom field I am adding a $ sign which may be messing up the calculation also but when I removed it I had the same result.
Any help here?
Thanks!
Comment #2
deggertsen commentedI just noticed that the first error I listed above does not appear to have anything to do with views calc. However I never had this appear before I tried using views calc and when I switched back to the normal table style the error went away. So what might be the relation here?
Comment #3
Wouter Van den Bosch commentedI'd like to confirm this error.
I use Custom Fields to add two PHP generated columns to my view. Those two columns I try to make a SUM of via the Calc module.
The results is the error below :
# user warning: Unknown column 'customfield.phpcode' in 'field list' query: SELECT MAX('') AS node_data_field_rekening_wouter_field_type_value, MAX('SUM') AS TOTAL_SUM, MAX('') AS node_data_field_rekening_wouter_field_rekening_wouter_value, MAX('') AS node_data_field_rekening_wouter_field_date_value, MAX('') AS node_data_field_rekening_wouter_field_date_invoice_value, MAX('') AS node_title, SUM(customfield.phpcode) AS customfield_phpcode_6, SUM(customfield.phpcode) AS customfield_phpcode_7 FROM node node LEFT JOIN content_type_transactie node_data_field_rekening_wouter ON node.vid = node_data_field_rekening_wouter.vid WHERE (node.type in ('transactie')) AND (node_data_field_rekening_wouter.field_rekening_wouter_value IS NOT NULL) AND (node.nid IN (520,519,518,513,507,517)) ORDER BY node_data_field_rekening_wouter_field_date_value DESC LIMIT 0, 10 in /Users/wvdbosch/Development/MAMP/dough_finances/sites/all/modules/views/includes/view.inc on line 755.
# user warning: Unknown column 'customfield.phpcode' in 'field list' query: SELECT MAX('') AS node_data_field_rekening_wouter_field_type_value, MAX('SUM') AS TOTAL_SUM, MAX('') AS node_data_field_rekening_wouter_field_rekening_wouter_value, MAX('') AS node_data_field_rekening_wouter_field_date_value, MAX('') AS node_data_field_rekening_wouter_field_date_invoice_value, MAX('') AS node_title, SUM(customfield.phpcode) AS customfield_phpcode_6, SUM(customfield.phpcode) AS customfield_phpcode_7 FROM node node LEFT JOIN content_type_transactie node_data_field_rekening_wouter ON node.vid = node_data_field_rekening_wouter.vid LEFT JOIN content_type_transactie node_data_field_type ON node.vid = node_data_field_type.vid LEFT JOIN content_type_transactie node_data_field_date ON node.vid = node_data_field_date.vid LEFT JOIN content_type_transactie node_data_field_date_invoice ON node.vid = node_data_field_date_invoice.vid WHERE (node.type in ('transactie')) AND (node_data_field_rekening_wouter.field_rekening_wouter_value IS NOT NULL) in /Users/wvdbosch/Development/MAMP/dough_finances/sites/all/modules/views/includes/view.inc on line 759.
The PHP generated columns work just fine without the calculations.
Best regards,
Wouter
Comment #4
BetaTheta commentedsubscribing
Comment #5
schvili commentedsubscribing
Comment #6
Hobbes-2 commentedsubscribing
Comment #7
jon_stewart commentedI had the same problem as deggertson (reply nr 2):
1. disabled and uninstalled views calc.
2. update core to 6.15
3. downgrade views 3.0 dev version to stable 2.8
4. ran cron
5 reinstalled patched views calc ie theme.inc is patched (there's a 'line 178' patch around that seems to do something)
Error went away. I still have logic errors I haven't got to the bottom of yet. Still working on those.
Hope this helps
PS there was no particular logic to why I cleaned up drupal, as above, just intuition!
UPDATE: Error only 'appeared' to go away!
Comment #8
thiswilldestroyyou commentedI tried the above steps, no luck.
having the same problem with this php
I just changed the code to 4 and got the same error, and then I tried a views global text with just 4 again and that also returns the same problem?
It has to be a views calc issue.
Comment #9
chansion.vc commentedHello,
I have the same problem.
When i remove the [Sort criteria], it's works fine.
I was try other version views ,and Views Calc module,but also erro~
I think the Sort criteria with the Views Calc Table - Sortable 《Conflict》
Hope it will help you
Sorry for my broken english.
Good luck
Comment #10
Rosamunda commentedI´ve been looking to be able to set a specific field with the difference between two views calc result, and not just two fields.
I´ve read that this code
Won´t work (using Views Custom Field).
How can I sum all post with the field X and rest all posts with the field Y?
Thanks in advance for your help!
Rosamunda
Comment #11
luco commentedsimpler problem here.
I'm using Views Custom Field to output a series of integer numbers (one per row), then adding such numbers with Views Calc. it returns an error, even with my code checking to see if they're all integers.
anyway..... subscribing. o/
Comment #12
adrianlawrence1976 commenteduser warning: Unknown column 'customfield.phpcode' in 'field list' query: SELECT MAX('') AS
I'm still having this exact same problem. Has no one found a fix yet?
Comment #13
miro_dietikerTry dev release once and report result.
Comment #14
miro_dietikerNote that views custom field calculates all data on the theming layer using PHP. Views Calc uses SQL to build the result.
It is absolutely impossibly to consider view custom field php code during the rendering process of Views Calc - since it is executed much before Views Custom Field does its calculations. We architecturally won't be able to fix this.
If you need more custom calculations, add them by SQL using the views calc fields.
Comment #15
Marko B commentedMiro, what you said makes sense, altough it would be nice to have custom field and views calc compatible.
My problem with views calc is this. I need to preproces field value before i can make calculation. From what i see I can't use PHP code in views calc field to do this, right? Can i make some custom function in "Allowable functions and operators:" to do this preprocessing?
What i want to do is to get a simple Avarage AGE from my users, to get age i need to preprocess their date od birth which is not hard when using custom field. Maybe a custom field for views calc field would be a good idea to solve this problem?