Ben Collins Profile picture
Apr 8 9 tweets 3 min read
Today I want to show you a quick way to add an ID column to your #GoogleSheets tables, using the SEQUENCE and COUNTA functions.

It's a quick way to see how many records you have in your table.

Let's go! 👇

(1/9)
We need a dataset for this example so let's grab an education dataset...

Here are some student test scores along with some variables that affect those scores.

(2/9)
Insert a new blank column on the left of this dataset. Add the title "ID" in cell A1 and this formula in cell A2:

=SEQUENCE(COUNTA(B2:B))

(3/9)
This generates a row ID in column A that auto-increments whenever you add new rows of data (provided column B is not blank).

It counts how many records there are in your table and generates an array of incrementing numbers 1, 2, 3, etc. matching the number of records.

(4/9)
It works great until you sort this data.

If you do that, this SEQUENCE function ends up further down your dataset because it moves with row 2 during the sort.

Yikes! 😱

(5/9)
The solution is to add this SEQUENCE formula to the header row, making use of an array literal formula.

More on those here: benlcollins.com/spreadsheets/g…

(6/9)
Delete the current ID header and the formula, and replace it with this formula in cell A1:

={"ID";SEQUENCE(COUNTA(B2:B))}

This puts the text "ID" in cell A1 and then generates the row IDs below that. Again, it auto-increments anytime a new row is added.

Nice!

(7/9)
⚠️ Important ⚠️

These ID numbers are not locked to their rows.

If you sort the data, the ID column will always show 1, 2, 3, etc. in order, because it's generated by the sequence formula.

(8/9)
If you want to lock the ID numbers to their rows, copy column A and paste as values.

Of course, this removes the auto-incrementing feature. 😔

Anyway that's it! I hope you found this tip helpful.

(9/9)

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Ben Collins

Ben Collins Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @benlcollins

Apr 7
Did you know you can publish your #GoogleSheets as web pages?

You can then share these web pages with the world, so people can see your Sheet as a distinct, lightweight webpage.

It's a good idea if you want to show the Sheet to a very large audience.

(1/3)
Here's an example:

docs.google.com/spreadsheets/d…

(2/3)
And here's how to do it:

1️⃣ Go to File > Share > Publish to web.

2️⃣ On the popup, select the Sheet (or Sheets) you want to publish and hit Publish.

3️⃣ Share the URL wherever you want!

There's even an option to embed the Sheet within an existing web page. 😃

(3/3)
Read 4 tweets
Apr 6
Yesterday I introduced the QUERY function using this formula:

=QUERY(A1:E100,"select B, D, E where D = 'Europe'",1)

It returns only columns B, D and, E, and only rows where column D is equal to "Europe."

Today's question: How can we change "Europe" to a certain cell, like G2? Image
Well, if you try to put the cell reference straight into the select statement it won't work, because the select statement is a text string.

Also, Europe is surrounded by single quotes, and these need to be included even when we reference another cell.

🤔
To reference another spreadsheet cell, we close the text string, reference the cell, and then open the text string again.

What the...?!
Read 6 tweets
Apr 5
The QUERY function in #GoogleSheets is pretty much the most powerful function in the spreadsheet world.

It operates on your data and has the functionality of many other functions, like sorting, aggregation, filtering, etc.

It's like a pivot table in function form.

(1/4)
It's a tricky function to learn because it's so different from regular functions. You use query language to write a statement that operates on your data.

Here's an example:

=QUERY(A1:E100,"select B, D, E where D = 'Europe'",1)

(2/4)
The function operates on data in the range A1:E100.

It returns only columns B, D and, E from that data in columns A to E, and applies a filter so that only rows where column D is equal to "Europe" are in the results.

Cool, right?

(3/4) Image
Read 5 tweets
Apr 4
10 powerful Google Sheets formulas advanced users should know: 🧐
1) QUERY

The boss for manipulating data, this function can do it all: sorting, filtering, aggregating, transforming...
2) SPARKLINE

Create miniature charts inside a cell with this function.

Great for adding context and trend information to data tables. ImageImage
Read 11 tweets
Dec 3, 2021
A great way to be more efficient in #GoogleSheets is to learn basic shortcuts for selecting data.

That's what I'm going to show you today - how to select data for formulas without your hands leaving the keyboard. ⌨️

It's so much quicker than grabbing the mouse! 🖱️
I remember how awkward it felt when I first learned these shortcuts, and how it was initially slower than just using the mouse to highlight the data.

But after a few days, it was significantly quicker than using the mouse. And it will be for you too.

Here we go ⬇️
1️⃣

Move quickly to the last non-blank cell in a row or column:

PC/Chromebook: Ctrl + ⬆⬇⬅➡
Mac: ⌘ + ⬆⬇⬅➡
Read 8 tweets
Dec 2, 2021
The OFFSET function is not a function you need particularly often, but it's worth knowing about because it allows you to move ranges around very easily.

#GoogleSheets thread. Let's go. 👇
The OFFSET function returns a reference to a range that is offset from a starting point in a worksheet.

For example, in the table shown in this image, imagine you want to align these columns at the top of the column.
The OFFSET function can do this with a single formula for each column, which is quicker and easier than copy-pasting or creating complex nested formulas.

The OFFSET formula in this example is:

=offset( B2:B6, 1, 0, count(B2:B6) )
Read 6 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(