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

Formatting Number Fields

Featured Replies

hey just a quick question, i want to get the number from a number field that may be in the format $299,000 or 299000 or 299,000 etc etc.. and put it in a hard format of $299,000 within a calc field, what number formatting functions if any would i use to do this?

cheers for help,

~genx

  • Author

If no-one is going to reply i'm going to use a work around and i know no one likes it when i do that hehe...

anyway, im thinking of just using a calc

Let([Price = GetAsNumber(PriceField); PL = Length(GetAsNumber(PriceField)] ;

Case(PL <= 3 ; "$" & Price ;

PL > 3 And PL <= 6 ; "$" & Left(Price ; PL-3) & "," & Right(Price;3) ;

PL > 6 And PL <= 9 ; "$" & Left(Price ; PL-6) & "," & Left(Right(Price ; 6); 3) & "," & Right(Price;3) ;

"Invalid Price" )

)

  • Newbies

Not sure if this is what you mean but select the number field that you want in Layout & then 'Number' under 'Format'.

Click the 'Format as decimal' button & tick fixed number decimal digits & key in '2'.

Click 'Use notation' with leading currency sign & choose '$' sign.

Then use the thousands separator a bit further down.

So a calculated result of eg 2987.46669 will display as $2,987.47.

Hope this helps

  • Author

... No, i need to hard format it with something like the textstyleadd function. Thanks anyway

Genx

The best one I've seen is by Comment:

Let ( [

// USER DEFINED:

input = numberfield ;

precision = 2 ;

currency = "$" ;

separator = "," ;

decPoint = "." ;

// DO NOT MODIFY FROM THIS POINT ON

inputRound = Round ( input ; precision ) ;

Amt = Abs (inputRound ) ;

Dollars = Int ( Amt )

] ;

// PREFIX

Case ( inputRound < 0 ; "-" )

& currency

&

// BILLIONS

Choose ( Dollars < 10 ^ 9 ; Right ( Div ( Dollars ; 10 ^ 9 ) ; 3 ) & separator )

&

// MILLIONS

Choose ( Dollars < 10 ^ 6 ; Right ( Div ( Dollars ; 10 ^ 6 ) ; 3 ) & separator )

&

// THOUSANDS

Choose ( Dollars < 10 ^ 3 ; Right ( Div ( Dollars ; 10 ^ 3 ) ; 3 ) & separator )

&

// UNITS

Right ( Dollars ; 3 )

&

// FRACTION

Choose ( precision < 1 ; decPoint

&

Right ( 10 ^ precision & Amt * ( 10 ^ precision ) ; precision ) )

)

Sorry I can't refer you to the post which generated it. This is the most flexible because you can define your own formats.

LaRetta :wink2:

The thread is here

http://www.fmforums.com/forum/showtopic.php?tid/152750

and it's important, because it gives credit to DJ as the original author.

  • Author

...Why are my calculations so ******* stupid looking compared to other peoples hehe.

Cheers guys, its perfect

~Genx

  • 2 months later...
  • Author

Finally got around to implementing it, works a charm.

Cheers,

~Genx

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.