3 Replies Latest reply on Jan 30, 2013 10:14 AM by philmodjunk

# Round function and always two decimals

### Title

Round function and always two decimals

### Post

Hi, i'am using filemaker 12 and we send the invoice by email as tekst.

We have different calculation but when we use the function round (amount ; 2) and the calaculation as an example is 10,50

it always returns to 10,5 in the email. It removes the 0 from it.

What we want is 10,50! Or always 2 decimal places.

I've searched the internet but no simple solution.

Perhaps you can help?

• ###### 1. Re: Round function and always two decimals

You will need to either attach the invoice as a PDF instead of using text or use a calculation that returns text that adds in any trailing zeroes to the right of the decimal.

Here is one possible calculation that does that:

Let ( [ n = Round ( YourTable::YourField ; 2 ) ;
i = int ( n ) ;
d = Left ( (n - i ) * 100 & "00" ; 2 )
];
i & "," & d
)

• ###### 2. Re: Round function and always two decimals

Thanks!

Somethimes it is 10,05.

With this function it makes 10,5?

Do you have a solution for this?

• ###### 3. Re: Round function and always two decimals

There's probably a more elegant way to do this but:

Let ( [ n = Round ( YourTable::YourField  ; 2 ) ;
i = int ( n ) ;
d = (n - i ) * 100;
d2 = Left ( if ( d < 10 ; "0" ) & d & "00" ; 2 )
];
i & "," & d2
)

Produces the correct results.