Skip to main content
Solved

How to round a number but keeping the trailing zeros?

  • October 6, 2023
  • 4 replies
  • 228 views

Kim_Trager1
Forum|alt.badge.img+23

I have some numbers i need to include in a string.

These numbers needs to be rounded down to two decimals, which I use ROUND() to do, my problem comes if the number has trailing zero's fx:

  • 233.50 becomes 233.5
  • 233.00 becomes 233

Does anyone know how can keep the trailing zeros? 

Best answer by Sho

It looks easy, but it was a bit of a challenge.

ROUNDDOWN({Number}, 0) & "." & IF( FIND(".",ROUND({Number}, 2)&""), REGEX_EXTRACT( ROUND({Number}, 2)&"0", "\\.(\\d{1,2})" ), "00" )

There has been a number field update recently, and it would be nice if formatted numbers could be used in Formulas as well.

 

4 replies

AirOps
Forum|alt.badge.img+10
  • Participating Frequently
  • October 6, 2023

Hi @Kim_Trager1 

You should be able to resolve this issue by specifying the precision on your formula field in the formatting tab when you edit a field. If your formula field is a number you should get a result like this where you can specify the decimal places you would like to be visible. 

 

 

 


Kim_Trager1
Forum|alt.badge.img+23
  • Author
  • Brainy
  • October 6, 2023

Hi @Kim_Trager1 

You should be able to resolve this issue by specifying the precision on your formula field in the formatting tab when you edit a field. If your formula field is a number you should get a result like this where you can specify the decimal places you would like to be visible. 

 

 

 


Thank you for this, however the number is part of a longer text. Like: "blablablabla £250.00 blablabla"

So it's how do I get the 250.00 to be "blablablabla £250.00 blablabla" instead of "blablablabla £250 blablabla"?


Forum|alt.badge.img+21
  • Inspiring
  • Answer
  • October 7, 2023

It looks easy, but it was a bit of a challenge.

ROUNDDOWN({Number}, 0) & "." & IF( FIND(".",ROUND({Number}, 2)&""), REGEX_EXTRACT( ROUND({Number}, 2)&"0", "\\.(\\d{1,2})" ), "00" )

There has been a number field update recently, and it would be nice if formatted numbers could be used in Formulas as well.

 


Kim_Trager1
Forum|alt.badge.img+23
  • Author
  • Brainy
  • October 7, 2023

This is beautiful, thank you so much. It was not as easy as I thought it would have been.