Trying to create an ID column and autoincrement each additional row created with Google Sheets

Hi folks,

This must be staring me in the face since I can't find any videos or forum posts about this. Autoincrementing seems to be covered by applications using a database, but I'm coming up short for Google Sheets solutions.

All I need is to be able to either start with a blank submission row where a column labeled "id" is 0 and every new submission grabs the most recent column and adds 1, or just count the rows and add 1.

Thank you!

Hi @samk, I had the same issue quite recently but not sure what's the timing you want this to happen but here's my hack on it. This is a simple solution if you are using 1,2,3,4... as your primary key.

  • On your GSheet, set column A as primary ID for that specific table.
  • Set A2 as 1 or whatever number you want to start at
  • A3 would be =if(B3,A2+1,) then drag that thing down.

Every time you append a row/entry in that sheet, the id for that row will be created. On your retool side, you have to refresh the data/run your gsheet resource to reflect the appended row containing its primary key (column A).

Ah! Thank you. I missed this response.

After submission is peachy keen with me. This will be used to give the submission a unique value that I can tell another team who picks up submissions "look for ID 123" since 3/10 submissions are from the same clients with identical information, I needed a reasonable length unique value.

I just set this up and it's working like a charm. Thank you!