Skip to main content
Topic: Projeblem when using custum fields (Read 2131 times) previous topic - next topic

Projeblem when using custum fields

Hello,

I've a table as on the image bellow where I've data from DB with quantity and price.
Them I creat a custom field where I multiply the quantity * price in order to get a total and I used the "format record field" along the columns in order to have them with the € sign.

I now want to have a "Field Footer Expression" on this custom field with the Sum of all the values I previously multiplied.

THE PROBLEM

If the multiplied field is configured as currency the "Field Footer Expression" SUM produces an error, but if it is configured as number I works ok and I can then configure the SUM as currency.
The thing is that I want both - The Costum Field with the multiplication - and the "Field Footer Expression" with the SUM of the multiplication with currency sign.

How can this be achived?

Re: Projeblem when using custum fields

Reply #1
@xela05‍ you cannot make a calculation on a string. once the value you are dealing with contains characters other than numbers, it is a string. In other to do calculations with them you need to convert t to an integer, double or float value. You can read more here PHP - How to Convert String to Float? (tutorialkart.com) to understand.
Code: [Select]
$product = (float) $value1 * (float) $value2