# E1 | deepseek/deepseek-v4-pro | 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 all values in column B where the matching cell in column A equals "Paid", use the **SUMIF** function, which works identically in both Microsoft Excel and Google Sheets.

## Formula

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

## How it works

**SUMIF** takes three arguments:

1. **Range to check** – `A:A` (entire column A)
2. **Criterion** – `"Paid"` (the exact text to match; case-insensitive by default)
3. **Sum range** – `B:B` (the column whose values are summed when the criterion is met)

The function scans every row in column A; when it finds the text "Paid", it includes the corresponding value from column B in the total.

## Practical example

| A       | B   |
|---------|-----|
| Paid    | 100 |
| Unpaid  | 200 |
| Paid    | 150 |
| Pending | 50  |

Placing the formula anywhere else returns **250**.

## Alternatives

- **Fixed range** (recommended for performance in large sheets):  
  `=SUMIF(A2:A100, "Paid", B2:B100)`
- **Multiple criteria** using SUMIFS:  
  `=SUMIFS(B:B, A:A, "Paid")` (criteria range first, then sum range)
- **In Google Sheets**, you can also use QUERY:  
  `=QUERY(A:B, "SELECT SUM(B) WHERE A = 'Paid' LABEL SUM(B) ''")`

## Important notes

- The comparison is **not case-sensitive**; "paid", "PAID", and "Paid" all match.
- If your "Paid" entries contain leading/trailing spaces, the sum will be 0. Clean the data or use a wildcard: `=SUMIF(A:A, "*Paid*", B:B)`.
- In Excel, using whole-column references (A:A) is fine for most workbooks; Google Sheets handles them efficiently as well.

Would you like to also count how many rows are marked "Paid" or apply a similar sum for another status like "Pending"?
