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.

Formatting Text as a Number in Merge Field...

Featured Replies

Hello all. I hope you are having a great weekend.

I am running into a problem that basically results in eye candy (nice but not totally necessary) on a report.

As of now, my Starting, Ending and Total Mileages do not have a comma separator. I would like to place a comma in the proper place in these fields.

The only things I can find online that pertains to this do not work for me no matter what I try (and I've spent hours trying). Here is what I have referenced...

Filemaker Help; Formatting Numbers in a Text Calculation Field and

Filemaker Help; How to Handle Formatting Number, Date and Time Merge Fields and Formatted Numbers Within Text Fields.

Here is the code I am using now...

If ( IsEmpty ( Mileage_Starting ); ""; "Starting Mileage: " & Mileage_Starting) & ¶ &

If ( IsEmpty ( Mileage_Ending ); ""; "Ending Mileage: " & Mileage_Ending) & ¶ &

If ( IsEmpty ( Mileage_Total ); ""; "Total Miles: " & Mileage_Total) & ¶ &

"Amount Due: $" & EarnedToday

Please bear in mind that the mileage figures are not always 6 digits in length. The could run anywhere from 1 mile to 1,000,001+ miles.

Also, the .00 on the back end of the Amount Due is not necessary. Most companies use rounded numbers.

Thanks in advance for any help with this matter.

Regards,

Charlie

post-102845-0-83606600-1351956150_thumb.

post-102845-0-92305000-1351956169_thumb.

How come you are using text?

  • Author

Because if there are no mileage figures, say the driver didn't drive that day, then I don't want the field labels appearing on the report as below. If I save the merge field as it is written and as a number, it returns only numbers formatted as below.

post-102845-0-05522800-1351973275_thumb.

post-102845-0-89261600-1351973288_thumb.

Try =

If ( not IsEmpty ( Mileage_Starting ) ; "Starting Mileage: " & NumToJText ( Mileage_Starting ; 1 ; 0 ) & ¶ ) &

... etc.

  • Author

That worked beautifully. Thank you!

  • Author

Hey Comment, Here's one for ya'...

Using the NumToJText function worked perfectly but I'd like to go a little further with the eye candy aspect if you (or anyone else) can help.

The problem; the field isn't shrinking on the printout and from what I can gather here, it has something to do with the JText function and using the TrimAll function as a fix.

I know the problem is within this field because when I removed it, everything else slid and shrunk perfectly.

Needless to say, the information contained in the link above is completely Greek Japanese to me. A sample of the printed field is attached.

As we would say down south, Thanky.

post-102845-0-06699600-1352050709_thumb.

Can you post the current version of your calculation?

  • Author

If (not IsEmpty ( Mileage_Starting); "Starting Mileage: " & NumToJText ( Mileage_Starting;1;0 );"") & ¶ &

If (not IsEmpty ( Mileage_Ending); "Ending Mileage: " & NumToJText ( Mileage_Ending;1;0 );"") & ¶ &

If (not IsEmpty ( Mileage_Total ); "Total Miles: " & NumToJText ( Mileage_Total; 1; 0);"") & ¶ &

If (not IsEmpty ( EarnedToday );"Total Due: $" & NumToJText ( EarnedToday; 1; 0))

If ( not IsEmpty ( Mileage_Starting ) ; "Starting Mileage: " & NumToJText ( Mileage_Starting ; 1 ; 0 ) & ¶ ) &

If (not IsEmpty ( Mileage_Starting); "Starting Mileage: " & NumToJText ( Mileage_Starting;1;0 );"") & ¶ &

Can you spot the difference?

  • Author

Yes, and thank you. I wasn't aware that you could close the parentheses outside the carriage return even though that is what you wrote in your earlier post. I guess you really can't get the full gist of a book by reading only half of each sentence, huh?

I wasn't aware that you could close the parentheses outside the carriage return

Why not? It's text, just like "Starting Mileage: ". To make it depend upon the test, include it inside the result of the If() function.

You can also use the List() function to achieve the same result:

List (

If ( not IsEmpty ( Mileage_Starting ) ; "Starting Mileage: " & NumToJText ( Mileage_Starting ; 1 ; 0 ) ) ;

If ( ... ) ;

If ( ... ) ;

...

)

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.