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.

Length of number field, including leading zeros

Featured Replies

I there any way to have FM calculate the length of a number field that will also count any leading zero digits?

Examples of what I'd like results to look like:

Number field data: 0012345 w/ length = 7

Number field data: 012345 w/ length = 6

What comes out instead:

Number field data: 0012345 w/ length = 5

Number field data: 012345 w/ length = 5

I've tried Length(NumToText(number_field)) and various permutations but can't seem to do this. Even exporting the data to a text (comma delimited, e.g.) file didn't work, as FM stripped the zeros during the export. I suspect this can't be done, but thought I'd check w/ y'all before giving up.

-Mike

Yeah, it looks like the Length() calc will count the leading zeros if it is a text field. This is probably because in math non-decimal leading zeros are ignored.

But if it is a text field, you lose your number field type features. I guess a sort-of workaround is to have a calc field = your number field with the result of the calc be text, then have your Length() calc field count this calc text field.

Ken

Why don't you just define the field as text then the Length() function will work. And you can still do math operations on the data. In fact there are very few situations where you really need to define a field as number.

Here look at this attachment.

  • Author

Unfortunately, I'm looking at a solution where the field has already been defined as type = number w/ ~30,000 records worth of data, or I'd definitely go with type=text. And the solution of making a number_text_format field w/ calc (text result) = NumToText (number_number_format) strips off the initial zeros.

Nice try, though.

-Mike

  • Author

Success!!

All I did was change the field definition for the Number field from type=number to type=text. That was all it took. All the data stayed exactly the same. I was expecting FM to remove all the zero's as part of the field type conversion, which is why I didn't try that earlier.

It makes no sense to me why this would work when all the NumToText and export stuff didn't, but there you are.

-Mike

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.