Sequential Numbers using Drag

Hello. In most spreadsheets you can click the corner and drag the cell to create sequential numbers and/or repeat text etc.

Is there a way to accomplish the same thing in Grist? And also, what about a formula that would accomplish this.

Thank You!

1 Like

Hi Chris!

This can be done using formulas. I created an example document that shows the options discussed below:

https://public.getgrist.com/1NenfgCTGrKv/Community-952

If you want the same value all the way down, you’d have a formula just equal to that value. Let’s say you have a column called ‘State’ and you want the same value all the way down to be Louisiana. The formula would be: = "Louisiana". You can see this in the 'Same Value Formula` column in the example table.

If you want to set a default value for new records, you can do that with a trigger formula. Using the State example, let’s say you want the default value to be Louisiana when a new record is created because most of the time, the state will be that but not necessarily all the time, so you want the ability to update it. You can see an example of this in the ‘Default Value’ column. It uses the same formula as before, = "Louisiana" but now it’s set as a trigger formula that only applies on new records.

When a record is created, it is assigned a unique Row ID. Using this in formulas allows you to create other unique numbers, like Order Number. To have sequential numbers that use the row ID, you can use the row ID in a simple formula. Check out ‘Sequential Numbers using ID’. Here, the formula is = 1000 + $id. So you have 1001, 1002, etc. I deleted Example 3 which was assigned Row ID = 3 so it jumps to 1004 so the numbers in this column remain unique to each record.

Let me know if you have any further questions!

2 Likes

Not OP, but going to jump in here since I was wondering about something similar relating to sequential numbering:

I’m trying to get a “site code” to generate automatically when a new site is made, with the site code being a two-character initial representing the city the site is in, followed by a two-digit number that is sequential based on how many other sites are in that city (e.g. when adding a new site in Townsville, which already has four sites, this new fifth site’s code would be TV05). Since the number doesn’t relate directly to the list of sites and instead relates to the number of sites in a particular city, I’m not sure I can use RowID for this.

I’ve tried the following (take the last site code and add one, basically):

ss_num = int(RIGHT(list(sorted(set((Sites.lookupRecords(City = $City).Site_Code))))[-1],2)) + 1

But then the system gets (kind of understandably) upset due to circular logic.

Any ideas on sequential numbering in a case like this?

1 Like

Sequential numbers come up in a few situations, and with different requirements. I put together this example to illustrate a couple of the scenarios, with recipes for achieving them:

https://public.getgrist.com/jiNnH5ULBknm/Sequential-Numbers/m/fork

  • How to keep sequential numbers that reflect the order rows are displayed in.
  • How to calculate sequential numbers within a group (@Parker_Smal 's question)
  • How to calculate sequential numbers that should not recalculate (as for check numbers)
4 Likes

Had to like the post because you used “Louisiana” as an example :slight_smile:

1 Like

@OSAcadiana_Jobs - Check out Webinar 7 - Custom Widgets for more Louisiana references :eyes:

1 Like

lol, I can’t believe how few people use GetGrist- it should be millions more than it is. Needless to say, I was shocked to see a Louisiana reference in such a niche product. Great to know there are other fellow cajuns plowing away in this space!

2 Likes