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.

Automatic Number Formatting?

Featured Replies

Hi All, I've got a number of fields that hold stock item pricing. I want to dynamically change the number of decimal places displayed based on the amount each item is priced at eg. $1.00 as two decimal places, $0.0755 as three decimal places, etc.

I can use an "If" statement to test but I'm not sure how to do the formatting.

Is this going to be possible using the calculation option on field setup?

Thanks Pedro ;)-)

Edited by Guest

Unfortunately, Filemaker's dynamic number formatting is very limited, so you will need to roll your own in a TEXT field. That shouldn't be too difficult, but your request is confusing. I understand you want a MINIMUM of 2 decimal places - but why should $0.0755 be displayed as three decimal places ($0.076)? What's the logic here?

  • Author

Hi Comment, thanks for your input, please have a look at my example below.

$0.76 x 10,000 = $7,600.00

$0.755 x 10, 000 = $7,550.00

I could display all prices as three or four decimal placs but this would look messy as most items are more than $1.00 each.

I was hoping I could have something like If (price < 1, #####.####, ####.##) etc.

Cheers Pedro ;)-)

Edited by Guest

I'm afraid I am getting even more confused here. I don't see what difference it makes if price < 1. I'd think the question is how many decimal places the price has:

$1.76 * 10,000 = $17,600.00

$1.755 * 10,000 = $17,550.00

And I still don't understand why $0.0755 should be displayed as $0.076.

  • Author

Hi Comment, sorry for the confusion, these fields display pricing that varies from > $50,000.00 to < $0.0011.

I need at least three/four decimal places on some prices but if I set the field to this on all prices it becomes to long for my printouts eg. $50,000.0000 takes more space than $50,000.00.

I was hoping to be able to display amounts > $1.00 with two decimal places and those < $1.00 with three or four. This way $50,000.00 and $0.0011 would display exactly as entered.

I'm just not sure if this is possible?

Thanks Peter ;)-)

It's possible - if the rules are clear. But you haven't answered my question and "at least three/four decimal places on some prices" is not very clear.

I am guessing something like this should work for you:

Let ( [

len = Max ( 2 ; Length ( Mod ( Price ; 1 ) ) - 1 )

] ;

"$" &

Int ( Price )

& "." &

Right ( [color:red]10^len & Price * 10^len ; len )

)

It looks at the actual number of decimal places, and if it's more than two it adds ALL the decimal places needed to accurately display the price.

I don't suppose it will be a problem in your case, but it should be noted that Price cannot be a negative number.

Edited by Guest
Fixed the portion in red

  • Author

Thanks Comment, your solution works very well.

I was originally planned altering the decimal places based on the value of the amount entered eg. lower values would display more decimal places than higher values.

Evaluating the actual number of decimal places required is better.

Cheers Pedro ;)-)

Edited by Guest

Good, but I'm afraid I have made a mistake - look at the edited version.

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.