Jump 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.

Break number into groups of 4 digits

Featured Replies

I'm looking for a field calculation that will break a number into groups of 4 digits, each group separated by a space. The number can have 5 or more digits (say up to 16). For example:

XXXXXXXXXXXXXXXX  to  XXXX XXXX XXXX XXXX

Strictly speaking, this is a looping calculation and requires either a recursive custom function or the While() function. However, if the input is limited to 16 digits or less, you could settle for a simple:

Trim ( 
Left ( Yourfield ; 4 )
& " " &
Middle ( Yourfield ; 5 ; 4 )
& " " &
Middle ( Yourfield ; 9 ; 4 )
& " " &
Middle ( Yourfield ; 13 ; 4 )
)

or, if you prefer:

Trim ( 
Replace ( Replace ( Replace (
Yourfield ; 
13 ; 0 ; " " ) ;
9 ; 0 ; " " ) ;
5 ; 0 ; " " )
)

This is assuming that the grouping should start from left - so that an input of 1234567890 will return "1234 5678 90".

 

Edited by comment

Genius on the 'Replace' (well to me.  To you it's just another day :) )

How would it look with the While ( ) function?

Just curious.

Thanks!

1 hour ago, Steve Martino said:

Genius on the 'Replace' (well to me.  To you it's just another day :) )

Actually, I stole it from here:
https://fmforums.com/topic/32095-how-to-format-a-numerical-field-to-show-as-smpte/?do=findComment&comment=145473

 

 

1 hour ago, Steve Martino said:

How would it look with the While ( ) function?

It could be =

While ( [ 
text = Yourfield ; 
start = 5
] ; 
start ≤ Length ( text ) ; 
[ 
text = Replace ( text ; start ; 0 ; " " ) ;
start = start + 5
] ; 
text 
)

 

Here's another option, perhaps a more intuitive one:

While ( [ 
text = Yourfield ; 
result = "" 
] ; 
not IsEmpty ( text ) ; 
[ 
result = List ( result ; Left ( text ; 4 ) ) ; 
text = Right ( text ; Length ( text ) - 4 ) 
] ; 
Substitute ( result ; ¶ ; " " )
)

 

Create an account or sign in to comment

Important Information

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

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.