# Automatic Sequential Numbering of Non-Sequential Items

No rush at all! You are a true king. Thx Justin.

Best,

Michiel

Sorry for the delayed response. Work has been keeping me very busy, and I havenât had time to put into working on the solution youâre seeking. Have you been able to get it working on your own, or do you still need assistance?

Yes, please. If you have time to have a look, would be very helpful. Thx!

Is there any easy way to adapt this to repeating unto 999? SO 1000 starts at 1 again?

Thank you!

Thatâs definitely doable, although mathematically it doesnât make sense to have 1000 turn into 1, and I couldnât get this to work cleanly in a formula considering how the numbering system is currently created. However, 1001 could become 1, as could 2001, 3001, and so forth; i.e. resetting to 1 after each multiple of 1000 has passed.

If that works for you, read on. If notâŚumâŚI guess you could read something else?

This is accomplished by tweaking the formula in the `{Variant}` field. The current formula is:

``````(LEN(Truncated) - LEN(Substitute)) / LEN({Unique Base})
``````

Hereâs the modified formula that cycles back to 1 after each multiple of 1000:

``````MOD((LEN(Truncated) - LEN(Substitute)) / LEN({Unique Base}) - 1, 1000) + 1
``````

However, that cycling behavior kind of defeats the purpose of the setup, which is to create a reliable count of specific items. If youâre tracking something so plentiful that youâve got 1000 of them, why would you want the count for that item to restart at 1? Are these items disposable. so that by the time you get to 1000, whatever was numbered 1 doesnât exist any more, and itâs safe to reuse that number?

Haha, it doesnât quite work, but I read on anyway

The point is to not get to a four digit number. I just realized, I probably could just take the right 3 digits using the RIGHT() function. I donât mind having a 000 number. Also, you are exactly right, by the time I get to 1000, I donât expect to be needing the first iteration of 001. This is being concatenated to the name of the linked record and I expect the linked record to only go up to 10, but am trying to be robust. The problem is, I donât want to have an infinite number of IDs to concatenate.

If I have 1000 records, then link 10 records to each of them, then the Auto ID would get to 10,000. However, I really only need it to go to 100. Itâs not a big enough deal for me to be willing to implement another table to iterate the record numbers like another example you have created. So I figured this was a reasonable and robust enough work around to keep each record name unique and readable.

Using RIGHT() wasnât quite that simple, haha. I had to first convert the nubmer to a string using the Arrayjoin() funciton. Then use a combination of MIN() and LEN(), because RIGHT() doesnât work if the input string is shorter than the number of characters you are asking for. But I for the result I was looking for

autoIDString
ARRAYJOIN({autoID})

Number
RIGHT(autoIDString,MIN(LEN(autoIDString),3))

IF({Number}, IF({Number}<10, â00â & {Number}, IF({Number}<100, â0â & {Number}, {Number})))

The `ARRAYJOIN()` function is designed to work on arrays, but the `{autoID}` field returns a number. I get the impression you just want to convert that number to a string, so all you need for that is to concatenate the number with an empty string:

``````autoID & ""
``````

The rest of the process to add leading zeroes to the number can also be greatly simplified. You only need a single formula. Hereâs what I often use when thatâs needed.

``````REPT("0", 3-LEN(autoID & "")) & autoID
``````

Broken down, that takes the autoID value, converts it to a string, subtracts the length of that string from 3 to see how many leading zeroes are needed, repeats the â0â character that many times, and concatenates that with the original number.

You show great refinement in your work! I never considered using the REPT() function. I did have to make one adjustment. You canât just feed autoID in, because once the numbers get above 5 digits long the REPT function returns an error. I am guessing this has to do with itâs ability to take negative values. Instead I used the Number field, which already reduces the auto ID to a maximum of 3 digits. Of course, this could be done in a single formula, but I like to break them out at first:

autoIDString
{autoID} & ââ

Number
RIGHT(autoIDString,MIN(LEN(autoIDString),3))

REPT(â0â, 3-LEN(Number& ââ)) & Number

Here is the single formula version

REPT(â0â, 3-LEN(RIGHT({autoID} & ââ,MIN(LEN({autoID} & ââ),3))& ââ)) & RIGHT({autoID} & ââ,MIN(LEN({autoID} & ââ),3))

I get where youâre going now, and can offer one more optimized version of your formula.

``````REPT("0", 3 - LEN(MOD(autoID, 1000) & "")) & MOD(autoID, 1000)
``````

The `MOD(autoID, 1000)` portion automatically reduces the numberâno matter how largeâto no more than three digits: the remainder after dividing the number by 1000.

On a side note, you used `Number & ""` in part of your formula, but the concatenation with the empty string isnât necessary there. Thatâs only required to take a non-string value and turn it into a string, but your `{Number}` field already created a string (the clue: left justification of the output means itâs a string; right-justification, as in the `{autoID}` field, means itâs a number).

This is perfect! Thanks!!

Hey @Justin_Barrett, thank you for your amazing work here !
Iâm using this method to make a pallet tracking base, where there is pallet 1 of 2, 2 of 2 etcâŚ
The issue I have is there is almost 12k pallet to track and each one is created via a script from the customer database and I wonât be on the field to do the trick and each pallet must be linked to the controler manually. (Iâm fairly new to the airtable world) I tried some sort of wizzardry with zappier to automatically link every new record created, but it doesnât works.

Is there a way to easilly link every new record created to the controler ?

Welcome to the community, @Thibaut_FERRI! Iâm a little less inclined to use this system these days thanks to Airtableâs scripting and automation features, but itâll still work if you want to use it. In terms of linking every new record to the control record, this can be done using Airtableâs automation system.

The trigger will be the creation of a new record. The action step will be an âUpdate recordâ action, where you update that record with the link to the desired control record. You can get the control recordâs ID by right-clicking on it and choosing âCopy record URLâ. In the automation update step, paste that full URL into the link field youâre updating, then delete everything except the actual record ID (e.g. recXXXXXXXXXXXXXX). Save and activate the automation, and all new records will auto-link to the control record.

Thank you very much, great community !
I still have a little issue with this one :

Iâd like to update the record in the control table when a record is created in the Etiquettes table. as you said Iâve used the control recordâs ID in the record id field, but what to put in the fields âetiquette fieldâ ?