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

How to find largest serial text value?


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

Recommended Posts

Posted (edited)

I have two files that use text keys defined as auto-enter serial values. For example, one file uses keys that progress as follows: A01, A02 ... A99, A100, A101 ... A999, A1000, A1001. I need to locate the "largest" key (A1001 in this example), but a simple sort does a column-by-column evaluation that results in A999 being deemed the largest. Is there a way to cause the sort to determime that A1001 is greater that A999? Or is this just an accepted problem when using alphanumric keys?

Thanks for any suggestions.

Edited by Guest
Posted

If all the serial numbers start with alphabetic part followed by a variable number of digits, then you can split out the numeric part with the filter function:

Filter (SerialNo;"0123456789")

into a separate field and then sort on that field. (This new field should be defined as numeric.)

You would be better off to set up your serial numbers to have leading zeroes (i.e., A00001...A01001) so that you don't run into this problem in the future.

Posted

Bob, instead of using filter, couldn't you just use get as number given that leading zero's arent really a factor here?

Posted

Thanks for the suggestions. I think the GetAsNumber approach will work for me.

To summarize: I'll loop through the records (there could be thousands) using GetAsNumber(TextID) to extract the numeric part, compare each against a $$Largest variable and replace the variable if the ID is larger than the current. Then I'll affix the letter to the final number to get the answer. Luckily this doesn't have to be done very often.

Posted

If the keys are FileMaker auto-enter serials, then the largest key must be the last one. Thus

Show All Records

Go to Record[ Last ]

Set Variable [ $$largest, Record::ID ]

This won't work if the order of records was modified somehow, e.g. by import.

Posted

That's exactly the case I'm dealing with: imported records ... which can have gaps (OK) when loading into an empty database, but I have to adjust the next serial value to avoid duplicate keys when creating new records.

(As a safety net, I want to make sure new values never track back over any existing key, hence the need to find the largest key and not trust any previous sequences.)

Posted

... Dont bother looping...

Create that extra calc field, mark a "cartesian?" -- "X" relationship between another TO, sort the records by your calc field, and then simply reference the related calc field -- if you've sorted correctly, the first related record (and the highest value) will be returned.

Posted

... or even as i just read Bob suggest, simply sort in a layout based on that TO, and go to the first record to collect your value.

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