# Calculated field for If/then statement

I am trying to figure out how to create a percentage paid field that will display the current most paid stage payment. i.e.

if the client has paid 10% percent only it will display 10 or 10%

If the client has paid 40% and 10% it will display 40 or 40%

and so on

I am currently trying to do this with IfElse but am not entirely sure if that is correct

if anyone could help that would be great

Parents
• Good morning Penny,

You could just do the math in your formula. I assume you have the total_amount and paid_amount.

so your percentage paid = paid_amount * 100 / total_amount

To get the decimal:

divide(multiply(\$paid_amount,100),\$total_amount)

you will likely want to round round that, for example to 2 decimals:

round(divide(multiply(\$paid_amount,100),\$total_amount), 2)

To get it as a string field with the % sign, you can turn it into a string

toString(divide(multiply(\$paid_amount,100),\$total_amount), 2))

and concatenate the % sign

concat(toString(divide(multiply(\$paid_amount,100),\$total_amount)), 2)))

Test this because it's off the top of my head and I didn't verify the syntax FrancescaS

• I recommend to add a check for avoiding division by zero errors, especially when this kind of formulas is introduced later on and you are having empty fields in records ;-)

ifElse(
or(equal(\$paid_amount,0),equal(\$paid_amount,"")),"0",
concat(toString(divide(multiply(\$paid_amount,100),\$total_amount)), 2)))
)

Bests

Björn