# E1 | meta/muse-spark-1.1 | run 1

## Prompt

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

## Response

This is done with SUMIF. The formula checks column A for the text "Paid" and only sums the corresponding values from column B.

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

## The Formula

**Syntax:** `=SUMIF(range, criteria, [sum_range])`

- `A:A` is the range to check [SUMIF Function](https://support.microsoft.com/en-us/office/sumif-function-169b8c99-1843-4e0e-872c-86d2f75ec55d)
- `"Paid"` is the criteria to match
- `B:B` is the range to sum [Google SUMIF Docs](https://support.google.com/docs/answer/3093583?hl=en)

Paste this in any cell outside columns A and B. It is case-insensitive and works identically in Excel and Google Sheets.

## Common Variations

If you have headers or want to limit the range for better performance, use explicit ranges:

```excel
=SUMIF(A2:A1000, "Paid", B2:B1000)
```

| Alternative Formula | When to Use It |
| --- | --- |
| `=SUMIFS(B:B, A:A, "Paid")` | Preferred in Excel for multiple criteria, e.g. `=SUMIFS(B:B, A:A, "Paid", C:C, "2024")` |
| `=SUM(FILTER(B:B, A:A="Paid"))` | Google Sheets modern approach, very readable |
| `=SUMPRODUCT((A:A="Paid")*B:B)` | Works in all versions, handles more complex logic |

## Handling Extra Spaces or Variations

If column A might contain " paid " or "Paid - Complete", use wildcards:

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

For trimmed exact matches in Google Sheets:

```excel
=SUM(FILTER(B:B, TRIM(LOWER(A:A))="paid"))
```

Do you need it to sum for multiple statuses at once, like 'Paid' and 'Partially Paid'?
