Jump to content

Automatic Number Formatting?


This topic is 5795 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 ;)-)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

This topic is 5795 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

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