I create a view with 2 numeric field (A and B), the I add new Global:Math expression (C) to it. I set value to field C use token replacements [field_a] - ['field_b']

Everything is ok until i format number (use comma thousand separator) and render field A as link. The field C return a incorrect value.
The problem is class views_handler_field_math simply use method floatval() to convert token value to float value , so it fail to convert formatted number to float value (http://cgit.drupalcode.org/views/tree/handlers/views_handler_field_math....)

I think we should unformat number for token value before evaluating expression.

Comments

howto’s picture

StatusFileSize
new3.15 KB

I add a patch. Please consider review and improve this patch.

ricobanga’s picture

This patch is working perfectly for me
it also allowed me to add a link on the field (aggregation counter) without breaking the Math expression and the sorting
Many thanks mister !

kenorb’s picture

Status: Active » Needs review
jordanmagnuson’s picture

Thanks for the patch! It's working for me. Though I'm somewhat shocked that this much code is needed.

nwom’s picture

Status: Needs review » Needs work

This doesn't seem to work with European decimals (comma as decimal, and period as thousands marker). Dividing two fields always results in 0.

jordanmagnuson’s picture

Patch no longer applies to latest views build.

suresh prabhu parkala’s picture

Status: Needs work » Needs review
StatusFileSize
new3.19 KB

Re-rolled patch. Please review.