Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Number rounding

Featured Replies

Does anyone have a function that can drop the last 3 '0's of a number and replace it with a letter?  For example:

 

$45,346 changed to $45K

$1,234.411 changed to $1,234M

 

Thanks in advance.

Here is an idea of an approach.  

Let ( [
numText = NumToJText ( num ; 1 ; 0 ) ;
commas = PatternCount ( numText ; "," )
] ;
Left ( numText ; Position ( numText ; "," ; 1 ; 1 ) - 1 )
&
Choose ( commas - 1 ; "K" ; "M" )
)

... extend this portion of the calculation out as far as you like by adding letters after the M.


BTW, when you say drop, I dropped.  If you wish for rounding you will need to make that adjustment.  :-)

NumJ.fp7.zip

  • Author

Thanks LaRetta,  I never noticed that function before.

  • Author

LaRetta,  One last question, how do I make a number over one million show as 1.23M with 2 decimal points?

Thanks again.

Try:

Let([

num = YourNumberField ;

T = Div ( Abs ( num ) ; 10^3 ) ;

S = Round ( Abs ( num ) / 10^6 ; 2 )

];

Case(

not T ; num ;

T < 1000 ; Sign ( num ) * T & "K" ;

Sign ( num ) * S & "M"

)

)

Nice Daniele!   :yep:

 

I wanted to mention that, when posting a calculation with Let(), it messes up when emails are sent.  It is best to place the calc within Code otherwise if someone uses the email instead of coming back here to get the calculation, it won't work.


BTW, I changed my post to include my entire calculation for those still on v11.

Hi Daniele,

 

Nice.

 

I would only add the filter to your number in case the raw data is as shown by RSComm i.e. $45,346 and $1,234.411

Let ( [
		num = Filter ( num ; "0123456789" ) ;
		T = Div ( Abs ( num ) ; 10 ^ 3 ) ;
		S = Round ( Abs ( num ) / 10 ^ 6 ; 2 )
	] ;
	Case (
		not T ;
		num ;
		T < 1000 ;
		Sign ( num ) * T & "K" ;
		Sign ( num ) * S & "M"
	)
)
  • Author

Thanks for all the help!

I would suggest =


Case (
number < 10^3 ; number ;
number < 10^6 ; Round ( number / 10^3 ; 0 ) & "k" ;
Let (
n = Round ( number / 10^6 ; 2 ) ;
Int ( n ) & SerialIncrement ( ".00" ; 100*Mod ( Abs ( n ) ; 1 ) ) & "M"
)
)

The two most significant differences between this and Daniele's method can be seen when number = 1999 (1k vs. 2k) and when number = 1999999 (2M vs. 2.00M).

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.