We do have customer views field handlers to format our cent values in various ways and would love to see the same support for views_calc too. However, we haven't found a way yet to patch that ourselves.

I can imagine too ways of implementing this: Either make more views field handlers available for selection in the table settings or - even more elegantly - just use the same formatting for the totals that are used for the detail values. That would be most powerful. Is it also possible?

Comments

Now found a very useful comment in the function views_calc_table_total() which states

            // Calculations other than COUNT should run the value through the field's theme.
            // This will allow dates and numeric values to apply the right formatting to the result.
            // Unfortunately, there seems to be no easy way to push an arbitrary value through
            // the field theme. The theme may be retrieving its value from the cached entity.
            // We would like to do $fields[$field]->theme($row), but that won't work.

I wasn't quite sure why that shouldn't work. Is it just because of possible caching? If that was the case, wouldn't it make sense to temporarily disable caching while processing those row(s) from views_calc?

If have now replaced
$vars[$key][$calc][$column] = number_format($row->$field_alias, $precision, $decimal, $separator);
with
$vars[$key][$calc][$column] = $fields[$field]->theme($row);

and that works perfectly fine for my case. I'd like to understand more about the limitations and maybe we can find a way to overcome them.