mzarin Posted May 22, 2003 Posted May 22, 2003 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
kenneth2k1 Posted May 22, 2003 Posted May 22, 2003 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
BobWeaver Posted May 23, 2003 Posted May 23, 2003 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.
mzarin Posted May 23, 2003 Author Posted May 23, 2003 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
mzarin Posted May 23, 2003 Author Posted May 23, 2003 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now