# E1 | z-ai/glm-5.2 | run 2

## Prompt

Write a spreadsheet formula (Excel/Sheets) that sums all values in column B where the matching cell in column A equals 'Paid'.

## Response

To sum values in column B based on a condition in column A, use the `SUMIF` function. The following formula adds all values in B where the corresponding cell in A equals "Paid":

```
=SUMIF(A:A, "Paid", B:B)
```

**How it works:**
- `A:A` — the range to check for the condition
- `"Paid"` — the criterion to match (text, so it must be in quotes)
- `B:B` — the range to sum when the condition is met

This formula works identically in both Excel and Google Sheets. If your data has a header row, the text in row 1 of column A won't match "Paid," so it won't affect the result.

Need to sum with multiple conditions instead (e.g., "Paid" in column A AND a specific date range)?
