Google Sheets for Beginners: Formulas, Queries, Charts, and Scripts
Key Takeaways
- Google Sheets formulas start with `=` and can perform math, text, and logic operations—e.g., `=SUM(A1:A10)` adds a column in one click.
- The QUERY function acts like SQL for your data: `=QUERY(A1:C100, "select A, sum(B) group by A", 1)` aggregates data without pivot tables.
- Charts in Sheets update automatically when data changes; use combo charts to compare different units (e.g., revenue vs. count).
- Google Apps Script lets you automate repetitive tasks—like emailing reports or clearing stale data—with JavaScript-like code.
---
Getting Started with Google Sheets
I remember my first spreadsheet: a mess of numbers and frustration. But Google Sheets is actually forgiving. It lives in your browser, saves automatically, and you can share it with anyone (no “track changes” drama). Let’s walk through the essentials.
Opening a New Sheet
- Go to sheets.new (yes, that URL works) or drive.google.com > New > Google Sheets.
- You’ll see a grid: rows are numbers, columns are letters. Every box is a “cell,” like A1 (column A, row 1).
Basic Navigation
- Click any cell to select it.
- Type text or numbers, then press Enter.
- To edit, double-click or press F2.
---
Formulas: The Workhorses
Formulas are where Sheets shifts from a digital napkin to a tool that thinks for you. Every formula starts with `=`.
Simple Math
- `=5+3` returns 8.
- `=A1+B1` adds the values in those cells.
- `=SUM(A1:A10)` adds all numbers in that range. I use this daily to total expenses.
Text Tricks
- `=CONCATENATE(A1, " ", B1)` joins first and last name with a space.
- `=LOWER(A1)` makes text lowercase (great for cleaning messy imports).
Logic for Decisions
- `=IF(A1>100, "High", "Low")` labels values based on a condition. I once used this to flag overdue invoices: `=IF(TODAY()-B1>30, “Overdue”, “OK”)`.
Real example: Say you have sales data: column A = product, B = units sold, C = price. Total revenue in D2: `=B2*C2`. Drag the bottom-right corner of D2 down to copy the formula for all rows. Done.
---
The QUERY Function: Your Data’s Best Friend
QUERY is like having a tiny SQL engine inside Sheets. It’s intimidating at first, but once you get it, you’ll wonder how you lived without it.
Syntax: `=QUERY(range, “query_string”, [headers])`
- Range: your data table (e.g., A1:C50).
- Query string: commands in quotes, using SQL-like language.
- Headers: 1 if your first row has labels.
Common Queries
- Filter rows: `=QUERY(A1:C20, “select * where B > 10”, 1)` returns only rows with more than 10 units sold.
- Group and aggregate: `=QUERY(A1:C20, “select A, sum(B) group by A”, 1)` gives total sales per product.
- Sort: `=QUERY(A1:C20, “select A, B order by B desc”, 1)` lists products from highest to lowest sales.
My tip: Always include the header row. If you get an error, check for typos in column letters—QUERY is case-sensitive for column names only if you use actual column letters (A, B, etc.).
---
Charts: Visuals Without the Pain
Charts in Sheets are reactive. Change a number, and the chart updates instantly. No manual adjustments.
Creating a Chart
1. Select your data (including headers).
2. Click Insert > Chart. Sheets guesses a chart type—usually a column chart.
3. In the Chart Editor (right panel), adjust:
- Chart type: Try line chart for trends, pie chart for proportions (but I avoid pie charts—they’re hard to read with more than 3 slices).
- Data range: Add or remove series.
- Customize tab: Change colors, add axis titles, tweak legend.
Example: I track monthly blog traffic. Column A = month, B = visits. A line chart shows the trend. But if I also have C = revenue, a combo chart (columns for visits, line for revenue) makes both visible without clashing scales.
---
Automation with Google Apps Script
This is where Sheets becomes a robot. Apps Script is JavaScript, but you don’t need to be a programmer to start.
A Simple Script: Send an Email
1. Open Extensions > Apps Script.
2. Replace the default code with:
```javascript
function sendEmail() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var data = sheet.getDataRange().getValues();
var email = data[1][0]; // cell A2
var subject = "Your Report is Ready";
var body = "Here is your data: " + data[1][1]; // cell B2
MailApp.sendEmail(email, subject, body);
}
```
3. Click the disk icon to save, then the play button to run (you’ll authorize it once).
Trigger it automatically: Click the clock icon (Triggers) > Add Trigger > choose “Time-driven” > “Every hour.” Now it runs without you.
Practical Automation
- Clear old data: A script that deletes rows older than 30 days.
- Create summary sheets: Pull data from multiple sheets into one master sheet.
- Send Slack messages: Use `UrlFetchApp.fetch()` to hit Slack’s webhook URL.
Caution: Scripts run under your account. Avoid infinite loops—always test with a copy of your data first.
---
Comparison: Formula vs. QUERY vs. Script
| Feature | Formula | QUERY Function | Apps Script |
| ------------------------ | ----------------------- | ----------------------- | ----------------------- |
| Best for | Quick calculations | Data aggregation | Complex automation |
| Learning curve | Low | Medium | High |
| Real-time updates | Yes | Yes | No (runs on trigger) |
| Can access other sheets | Limited (via IMPORTRANGE) | Limited (via range) | Full control |
---
FAQ
1. Why does my QUERY return an error when I use `where`?
The most common mistake: forgetting to reference column letters correctly. If your range is A1:C10, use `where A > 5` (not `where A1 > 5`). Also, text values need single quotes: `where A = 'Apples'`. Check for hidden spaces in your data—use `trim()` in a helper column.
2. Can I share a script with someone else?
Yes, but they need access to the sheet. Scripts are tied to the sheet, not to you. When they open it, they’ll see your script in Extensions > Apps Script, and they can run it (they’ll need to authorize it themselves). For broader distribution, publish the script as an add-on.
3. How do I make a chart that updates when I add new rows?
Use a dynamic range: either convert your data to a Table (Data > Create a Filter) or use an open-ended range like `A1:B1000` in your chart data. Better yet, use a QUERY as the chart source: `=QUERY(A1:B, “select * where A is not null”)`—this ignores blank rows and automatically includes new data.
---
Final thought: Start with formulas, then QUERY, then scripts. Each layer solves a bigger problem. And remember: there’s always an undo button (Ctrl+Z) if you mess up. I’ve used it more times than I’ll admit.