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.

CommentFileSizeAuthor
#2 decimal.jpg31.05 KBIWasBornToWin
ViewExportDecimalProblem.txt11.79 KBGlenmoore

Comments

IWasBornToWin’s picture

Same problem here

IWasBornToWin’s picture

StatusFileSize
new31.05 KB

I 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

http://drupal.org/files/decimal.jpg

merlinofchaos’s picture

Note 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.

IWasBornToWin’s picture

@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

dawehner’s picture

Well you can use for example the global: math field and round it.

IWasBornToWin’s picture

@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

IWasBornToWin’s picture

Merlin, can you answer #4 please? Thanks

IWasBornToWin’s picture

Anyone have an answer to #4? Thanks

dawehner’s picture

Category: bug » support
Status: Active » Fixed

I have to admit that this is not as easy as i first thought though this is possible with the global: math field ...

round([value]*100)/100
IWasBornToWin’s picture

You just made my night! Awesome...thanks

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

ashi anand’s picture

Issue summary: View changes

I 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