# Help with a calculation

## Recommended Posts

• Newbies

I am new to FM and am wanting some help with a calculation. I have four fields, rate1 & rate2, quantity & result. What I am trying to figure out is how to have a calculation that will calculate the result of the value in the quantity field divided by the rate where if the field rate2 has no data (is empty) the calculation formula will use rate1 to calculate the result. However if there is a value in the field rate2 then the result should be calculated based on this rate2 and not use the value found in rate1.

Appreciate any direction and help.

Thanks

##### Share on other sites

Quantity * GetValue (  List ( Rate2 ; Rate1 )  ; 1 )

##### Share on other sites
• Newbies

Thanks thats exactly what was needed. Works as I wanted.

##### Share on other sites
10 hours ago, Malcolm99 said:

if the field rate2 has no data (is empty) the calculation formula will use rate1

IMHO it would be much simpler to do exactly what you said:

`quantity / If ( IsEmpty ( rate2 ) ; rate1 ; rate2 )`

instead of converting the values to text, stacking them into a list, extracting the first value from the list and converting it back to number.

• 1
##### Share on other sites

After second thought I would agree that what @comment suggests is actually better.

## Create an account

Register a new account