Help creating auto-increment ID column (tried all formulas — not working)

Hi everyone,

I’m trying to create an auto-increment (sequential) ID column in my table (like 1, 2, 3, 4…) that automatically adds the next number when a new row is created.

I’ve already tried different formulas, including:max([r.Seq for r in Tables[‘Main’].all if r.Seq is not None] + [0]) + 1
max([r.Seq for r in Main.all if r.Seq is not None] + [0]) + 1
and variations likemax([r.Seq for r in Main.all if r.Seq is not None] + [0]) + 1

Are you aware that there’s a built-in ID field in each table that acts as the unique identifier for the row? It seems to be an auto-incrementing sequence number, which you can surface as a table column by setting the formula to “$ID”.

Would that give you what you need?

For some reason this also doesn’t work

Hmm. Let’s try the specific steps - maybe you’re starting from the wrong point somehow? Anyway, try this:

  • Start with any table with at least a few records already in it.

  • Click on the drop-down of the first column, go down to the end, and tell it to insert a column to the left (new first column, although that doesn’t matter).

  • Select “Add formula column” from the next menu.

  • In the formula field, type just “$id” (no quotes, all lower case.)

    The new column should be populated by a bunch of inique integers, that are the automatically created and maintained internal ID numbers of each of those records.

If that doesn’t work and reveal why it wasn’t working for you before, post back with more details. Good luck!

1 Like