Automatic Sequential Numbering of Non-Sequential Items

@Justin_Barrett – terrific work! I’d simultaneously been working on a sequential numbering routine that restarted automatically each day, allowing such things as ‘03/31/2019.1’, ‘03/31/2019.2’, ‘03/31/2019.3’, and so on, but you beat me to the punch. (I went ahead and posted it, anyway — but it appears Discourse can’t easily differentiate between self-deprecating humor and other-deprecating invective [unsurprisingly], so my post awaits moderator approval… .) Your solution is better, though, being more general-purpose.


Edit: A-ha! Here 'tis.

3 Likes

Just looked at the example table and this is EXACTLY what we need! Is there any way you would be willing to help me set this up? I’d be happy to share my work e-mail address so we don’t have to keep coming back to this thread.

Thank you! I am so excited about this!

I’d be happy to help you set this up, Sara. Send your email address via PM and we’ll get rolling!

@Justin_Barrett I found this show and tell-and it is AMAZING! I made a copy of your base and played with it to make sure it would work if I used dates as the base-and it did. But when I incorporated it into my company’s CRM-it didn’t work :frowning:

Instead of the variant being unique it just states the total number of of records with that date. I have tried recopying the formulas but to no avail.

Would you or someone be willing to take a look at it for me?

Thank you!

Devonna

Yes, I’d be happy to take a look at it, though I won’t have time to do so until later tomorrow afternoon. I’ll let you know what I found after reviewing what you shared.

1 Like

Thank you! I poked around and noticed that some records are responding as expected while others are not. Which makes it more confusing. The screen shot below shows both cases.

The issue with @Devonna_Wolfe’s base, and with another base that I fixed a while ago, has to do with the autonumber field that’s a required part of the system. I’m not able to edit my original post any more, so I’m adding the relevant details here.

Summary
Deleting a record in the main table will break the automatic sequencing of any items after that point. Thankfully there’s a simple fix: Change the autonumber field to a single line text field, save the change, then change it back to autonumber. This will force Airtable to rebuild the numbering sequence, and the sequence numbering will be correct.

The Long Version
When I was initially testing this system, I somehow didn’t think to test how deleting records would affect the calculations. Some of those calculations are based on the number of records in the table, and some are based on the hidden autonumber field that’s integral to the system. In theory those should always stay in sync. However, once a record is deleted, the numbering will be out of sync from that point on. For example, if your main table contains 200 records, but you delete record 90, records 91 onward won’t be synced properly. Thankfully the above fix takes just a few seconds, and will correct the problem.

One way to be alerted automatically when the numbering scheme gets out of sync is to make a field named {Sync} containing the following formula (replacing {Unique Base} with your own field name if necessary):

IF(LEN(Truncated) != Autonumber * LEN({Unique Base}), "❌")

I have not been able to get past this step of the system. It seems to break whenever I add the {Unique Base} into the substitute formula in place of the old text variable. This is the formula I am using which results in an error. Is there a different formula that should be used here?

SUBSTITUTE(Truncated,{Unique Base},"")

Welcome to the community, @Weston_Beaumont! :smiley: That’s the correct formula, assuming that you used those exact names for your fields when building this system in your own base. What kind of error message are you getting? Does Airtable allow you to save that formula, or is the error appearing in the formula field setup dialog?

Note: for the next 48 hours I’ll be largely unable to respond as we drive across the country to our new home. I’ll reply as soon as I can after that.

The field names match and I have been using the drop down from the formula field in order to make sure the field names are correct. The error shows up in the cells after the formula field is saved. This has to be a problem related to the field format.

This formula works (in a limited sense since the ID needs to be dynamic with the record type)
SUBSTITUTE(Truncated,“001|”,"")

This formula does not work, The brackets around the Unique Base name are interesting.
SUBSTITUTE(Truncated,{Unique Base},"")

Can you be more specific? What kind of error do you see?

When referencing a field that’s more than just a single word, or one that has emoji or other non-alphabetic characters in its name, the name must be wrapped in curly braces for the formula to operate properly.

Hi there! I have been looking for a good solution to my issue and I see many posts linked to this article. But looking at @Justin_Barrett instructions, I am unable to solve this.

I’m using Airtable for an administration system where people add their receipts. Every receipt needs to have a unique number. Preferably I have a SETTING view where I can set the code of the receipt and give a starting number of the sequence.

For example I will have TB1-001 (where TB1 is the code) and the 001 is set due to my starting number of the sequence, which is 1.

I can share my table to give you an insight to my challenge. Thx

Hi, there! Total spreadsheet / Airtable n00b here. :sweat_smile:

First, let me say that if anyone would like to reach out to help me out with this, I’d be more than happy to compensate them for their time.

I think what I’m trying to accomplish is along these lines.

Goal: A table that adds a new record numbered 1-10 and RESETS to number 1 once 10 is reached.

Reason: I run a real estate team and I need to assign them leads as they come in to our system in an equitable manner.

Background: I’m fairly fluent in Zapier and could easily send these records to Airtable but I can’t seem to find a way to distribute them to my 10 person team evenly as they come in.

Question: Is this actually a good use case for my problem or am I barking up the wrong tree? Is there a much easier solution I’m not seeing?

Spreadsheets are my kryptonite so thanks in advance for any / all insight / advice.

PS: I will totally pay you to set this up for me!

-Keith

Welcome to the community, @Michiel_Haverlag! :smiley: If you’re able to share a link to your base, feel free to post that here. I’m a lot busier these days with my new job, and can’t always do deep dives into problem setups, but I’m hoping this will be an easy fix.

The setup you want can be done with a much simpler setup than what I described above. In your case, you would begin by adding an Autonumber field. I often name these with a number/pound sign so I can shrink it down fairly small:

Add a formula field with this formula:

MOD({#} + 9, 10) + 1

Which will give you this:

Hi Justin,

That would be amazing. I have duplicated my base where you could play around:

https://airtable.com/invite/l?inviteId=invyZBCb87e7y50cA&inviteToken=5411d318faed83d12f36c4ca47cb30855985d64d7defcec5960e9c5adccd3ab1

So basically there is just one column that needs to be a sequence which needs to be plussed by one. Example: if I have 4 receipts in the table and I add a new one, the field should say 5.

If I delete no. 5 and add a new one, this integer should say 5 again. Hope it is clear to you. I don’t think it is hard mathematics for you.

Thanks in advance :slight_smile:

Michiel

Michiel,

I was about to dive into this, but after reading through your comments, one thing stuck out:

This is a known issue with the system I came up with. In a follow-up post above, I pointed out:

This is because a core element of the system is an Autonumber field, and Autonumber fields never repeat numbers, even if a record is deleted. The only way to “fix” this is to tweak the Autonumber field (as I outlined above) to reset it. This wouldn’t be much of a bother if you seldom delete records. However, If you foresee yourself deleting records regularly, you’ll have to apply this reset to the Autonumber field every time you do so, which would become more than a bit annoying IMO.

Hi @Justin_Barrett,

Ok. In that case we will change our workaround and won’t delete the records but change them :slight_smile: If we would do that, would that change things and could you proceed with your magic?

That will work if you don’t delete records, but just know that it may be a day or two before I can work on it. I’ve already got a very full plate at the moment.

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

Best,

Michiel