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 7319 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi everyone,

I have a calculation field that has text and numbers in it. It is basically a conversion field. The user enters one value in the "Qty Convert" field and then chooses the unit in the "from" field and the unit in the "to" field. The calc field displays something like:

100 Kilograms = 3527.396198 Ounces

My problem is that I have to make the calc a text field not a number field so I can't format the number to include the thousand separator. I have a fairly long calculation to do this but is there an easier way? I would also like to add a million separator in the unlikely event that it is needed.

Any help is greatly appreciated

Posted

Use four fields: a number field (for the original quantity, formatted with the thousands separator), a text field for the From units, a text field for the To units, and a number field for the result (formatted with the thousands separator).

Posted

Thanks for replying so quickly,

I tried that but then I have a spacing problem. Although it is just Aesthetic it is annoying. I have to make the number fields big enough to accomodate 7 places on both sides of the decimal point and the slide left doesn't help. Is there another way to make it more continuous?

Posted

Thank you guys this is great

I used Di Luca's Calc and it worked great. But just to cause touble is there a way to eliminate the unused zeros? I want to be able to have 7 digits past the decimal but only when they are needed.

Thanks again

Posted

Try substituting the last portion of the calc (starting with "Choose( Precision = 0") with

Let( P = Min( Precision; Length(Substitute( GetAsNumber( "." & Right( Number; Length(Number) - Position( Number & Case( not PatternCount( Number; "." ); "." ); "."; 0; 1 ) )); "."; "" )) );

Choose( P = 0 ; "." &

Right( 10 ^ P & Abs( Round( Number ; P ) )

* ( 10 ^ P ) ; P ))

)

Posted

Right. I was thinking that Mod might return screwy results here, but I guess that was Int I was remembering.

In that case, ditch the above suggestion and go with

Let( P = Min( Precision; Length(Mod( Number; 1 )) - 1 );

Choose( P = 0; "." &

Right( 10 ^ P & Abs( Round( Number ; P ) )

* ( 10 ^ P ) ; P ))

)

Posted

Those work great for anything 7 decimal places and less. But anything with more rounds off and leaves the 7 zeros. I can't thank you guys enough for your time, I really appreciate it.

Posted

I still don't get it. This, IMHO, is all the modification required:

Choose( (PRECISION <= 0) [color:"red"] or not Mod( NUMBER , 1 ) , "." &

Right( 10^PRECISION & Abs( Round( NUMBER , PRECISION ) )

* ( 10^PRECISION ) , PRECISION ))

Posted

He doesn't want the trailing zeroes, which is why I used a dynamic precision.

Posted

Okay, this one seems to work well.

Let([ M = Mod( Number; 1 ); P = Min( Precision; Length(Round( M; Precision )) - 1 ) ];

Choose( P <= 0; "." &

Right( 10 ^ P & Abs( Round( Number; P ) )

* ( 10 ^ P ) ; P ))

)

Posted

Oh. Sorry, I completely misunderstood. I thought he wanted to cut off the trailing zeroes in case the number was an integer.

P.S. I still think it should be P <= 0.

Posted

I couldn't figure out why until I entered some negative precisions. Without it, the decimal point appears at the end of an integer. Good call. I modified the calc above to include it.

I also broke negative Number values. It's fixed now.

Posted

Here's another variant (you're not the only one bored):

Choose ( Precision <= 0 ; "."

&

Middle (

Abs ( Mod ( Round ( Number ; Precision ) ; 1 ) ) ;

2 ; Precision + 1

) )

This topic is 7319 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.