I originally thought this might be a "Computed Field" problem but I think it may actually be a Views problem as the data appears to be stored correctly in the db.
I have two fields, both stored as "decimal(10,2)" in the db.
Field A is a 'decimal' field created by the Computed Fields module and Field B is a simple cck 'decimal' field.
However, when I insert them into a View, I am offered formatting options (decimal places etc) only in the case of the 'cck' field. This may sound trivial but, whilst Views respects the preset number of decimal places when displaying the field ordinarily, it displays 6 decimal places when the field is aggregated (averaged) making the View unuseable (as it has many similar fields in it).
I have attached a copy of the trimmed down View but I dont think it gives any further useful info.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | decimal.jpg | 31.05 KB | IWasBornToWin |
| ViewExportDecimalProblem.txt | 11.79 KB | Glenmoore |
Comments
Comment #1
IWasBornToWin commentedSame problem here
Comment #2
IWasBornToWin commentedI just ran a test with a test field as decimal type and it worked like a charm. I totaled 2 values fromn the decimal field and view aggregate averaged it out to two decimal places. Here's a screen shot of the settings
Comment #3
merlinofchaos commentedNote that one problem is that Views does not do conversions on your tokens. If your field is being displayed as "$1.23" (for example) then that appears as a string which converts to 0 when utilizing the math functions.
Comment #4
IWasBornToWin commented@merlin - If my integer field is being displayed as 53.3333 is there a simple way to get it to display as 53.33?
I just tried a float and it displayed as 53.3333333333
and integer displays as 53.3333
decimal works great but I need a field I can use on radio formatter. (which is integer, text, or float)
text works too but it displays as 58.3333333333333
Comment #5
dawehnerWell you can use for example the global: math field and round it.
Comment #6
IWasBornToWin commented@dawehner I've tried to use the global math field. First, i don't know what formula to use to round it. Second, it tried to aggregate that field also....so, since I had 3 records in my calculations and one of them had a value of 0 I got an error. I was hoping I could use the math field too. I could try rounding it, do you know the formula to use?
Thanks
Comment #7
IWasBornToWin commentedMerlin, can you answer #4 please? Thanks
Comment #8
IWasBornToWin commentedAnyone have an answer to #4? Thanks
Comment #9
dawehnerI have to admit that this is not as easy as i first thought though this is possible with the global: math field ...
Comment #10
IWasBornToWin commentedYou just made my night! Awesome...thanks
Comment #12
ashi anand commentedI solved this issue by using
$display_output = intval($entity_field_item['value']);in the display (code) field setting of the computed field ... views automatically shows the integer value