Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

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

Recommended Posts

Posted

Hello,

I have a calculation field that incorportates both Text and Numbers. I would like to format the numbers to have thousands seperator, but the calculation result has to be Text; given that, is there anyway to format the numeric values within the calculation? I tried to format the field in the Layout view by clicking on the merge field and then going Format->Number, but it didn't do anything (which makes sense since the result is being formatted as Text). Is there a function that I can use line by line within the calculation?

Thank you for your assistance.

Regards,

Jason

Posted

Hello,

I have a calculation field that incorportates both Text and Numbers. I would like to format the numbers to have thousands seperator, but the calculation result has to be Text; given that, is there anyway to format the numeric values within the calculation? I tried to format the field in the Layout view by clicking on the merge field and then going Format->Number, but it didn't do anything (which makes sense since the result is being formatted as Text). Is there a function that I can use line by line within the calculation?

Thank you for your assistance.

Regards,

Jason

Posted

The only way that I know of is to create a calculation to parse the number and insert the commas.

I am sure there is a cleaner and shorter way to do this, but this still works:

If the field name is: testnum

And the number is: 1256743.20

And the desired result is: 1,256,743.20

USE:

// Millions

if(

length(int(testnum)) > 9,

right(left(testnum, length(int(testnum)) - 6),3),

left(testnum, length(int(testnum)) - 6)

)

&

// Millions Comma

if(length(int(testnum)) >6 , "," , "")

&

// Thousands

if(

length(int(testnum)) > 6,

right(left(testnum, length(int(testnum)) - 3),3),

left(testnum, length(int(testnum)) - 3)

)

&

// Thousands Comma

if(length(int(testnum)) >3 , "," , "")

&

// Hundreds

right(int(testnum),3)

&

// Cents

case(

length(testnum - int(testnum)) = 3, (testnum - int(testnum)) ,

length(testnum - int(testnum)) = 2, (testnum - int(testnum)) &

Posted

Try this:

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

)

Posted

This worked, thanks! I'm just going to insert the commas in the Grand Total because it would be quite tedious to stick that calculation for each of the line items. Thanks again!

Regards,

Jason

Posted

Ack! I accidently omitted the line for displaying the negative symbol. I probably should have just copied one of my old calcs that I use instead of attempting to make one on the fly. It would have been a lot more complete, though a bit longer as my skills have increased as more time passes.

No matter! Comment has done a far superior job in any case. As I suspected, there is a far better and shorter way to accomplish parsing a number to insert commas.

I will be making use of this in my conversions for certain.

Thanks Comment!

This topic is 7253 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
×
×
  • Create New...

Important Information

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