To sum values in Google Sheets only when a checkbox is checked, use the SUMIF function with the checkbox column as the criteria range and TRUE as the criterion: =SUMIF(A2:A10, TRUE, B2:B10). This adds up all numbers in column B where the corresponding cell in column A contains a checked checkbox.
How Checkboxes Work in Google Sheets
Checkboxes in Google Sheets are inserted via Insert > Checkbox (available on the toolbar or the Insert menu). When you insert a checkbox into a cell, that cell’s underlying value is a boolean: TRUE when checked, FALSE when unchecked. This is a key point—a checkbox is not a special object; it is a data validation rule that displays a tick box but stores a logical value. Because of this, you can use checkboxes directly in formulas just like you would use any TRUE/FALSE value.
If you type =A2 in a cell where A2 contains a checked checkbox, it returns TRUE. Unchecked returns FALSE. This boolean nature is what makes SUMIF and SUMPRODUCT work seamlessly with checkboxes.
The Basic SUMIF Formula
The simplest approach uses SUMIF with three arguments: the range to check, the criterion, and the sum range.
- Range: the column containing the checkboxes (e.g., A2:A10).
- Criterion:
TRUE(or the cell reference to a TRUE value). - Sum range: the column with the numbers you want to add (e.g., B2:B10).
Example: Suppose you have checkboxes in A2:A10 and amounts in B2:B10. The formula =SUMIF(A2:A10, TRUE, B2:B10) returns the total of all amounts where the checkbox is checked. If B2=10, B3=20, B4=30, and only A2 and A4 are checked, the result is 40.
Note that SUMIF treats TRUE as a text criterion, not a logical value. In Google Sheets, it works because the criterion is matched against the stored boolean. You can also use 1 as the criterion if you prefer, since TRUE is equivalent to 1 in arithmetic contexts, but TRUE is clearer.
Using SUMPRODUCT for More Flexibility
If you need to sum based on multiple conditions—for example, checked checkboxes and a category in another column—SUMPRODUCT is a powerful alternative. The syntax is: =SUMPRODUCT((A2:A10=TRUE)*(C2:C10="Food")*B2:B10).
This works by multiplying the boolean arrays: each TRUE in the checkbox column becomes 1, each FALSE becomes 0, and the same for the condition on column C. The multiplication yields 1 only when both conditions are true, and then multiplies by the amount in column B. Summing those products gives the total. For example, with checkboxes in A2:A10, categories in C2:C10, and amounts in B2:B10, the formula returns the sum of amounts where the checkbox is checked AND the category is “Food”.
Unlike SUMIF, SUMPRODUCT does not require the ranges to be the same size, but they should be to avoid errors. It also handles array operations natively, making it ideal for complex criteria.
Common Problems and How to Fix Them
Several issues can arise when using checkboxes with sum formulas:
- Checkbox not recognized as TRUE: If you manually typed the word “TRUE” in a cell instead of inserting a checkbox, it is text, not a logical value.
SUMIFmay still match it, butSUMPRODUCTmight not. Always insert checkboxes via the menu. - Sum range includes checkbox column by mistake: Double-check that the sum range is the correct numeric column. A common error is using
=SUMIF(A2:A10, TRUE, A2:A10)which sums 1s and 0s, not your amounts. - Empty cells in sum range: If some cells in the sum range are blank,
SUMIFignores them. That is fine, but if you have zeros, they are included. - Using
SUMIFwith a range that contains both checkboxes and numbers: Keep checkbox columns separate from numeric columns for clarity. - Locale differences: In some European locales, the argument separator is a semicolon (;) instead of a comma. If your formula returns an error, try replacing commas with semicolons.
Another common misconception: some users try =SUMIF(A2:A10, "checked", B2:B10). That will not work because the checkbox value is TRUE, not the text “checked”. Always use TRUE or FALSE as the criterion.
Conditional Formatting to Visualize Totals
You can combine checkboxes with conditional formatting to highlight rows that are checked or sums that meet a threshold. For example, to highlight the entire row when the checkbox in column A is checked:
- Select the data range (e.g., A2:C10).
- Go to Format > Conditional formatting.
- Under “Apply to range”, confirm the range.
- Under “Format rules”, choose “Custom formula is”.
- Enter
=$A2=TRUE(note the absolute column reference). - Set a fill color and click Done.
This makes it easy to see which items are included in your sum. You can also use conditional formatting on the total cell to change color if the sum exceeds a certain value, using a formula like =B12>100.
Alternatives: SUMIFS and QUERY
If you have multiple criteria, SUMIFS is a direct alternative to SUMPRODUCT and is often easier to read. The syntax is: =SUMIFS(sum_range, criteria_range1, criterion1, [criteria_range2, criterion2, ...]). For checkboxes, you would write =SUMIFS(B2:B10, A2:A10, TRUE, C2:C10, "Food"). This sums column B where column A is TRUE and column C is “Food”.
Another powerful option is the QUERY function, which uses a SQL-like syntax. For example: =QUERY(A2:C10, "select sum(B) where A = TRUE and C = 'Food' label sum(B) ''"). This returns the sum directly. QUERY is more verbose but very flexible for complex aggregations, such as grouping by category.
Each method has its strengths: SUMIF is simplest for a single condition, SUMIFS is clearer for multiple conditions, SUMPRODUCT is best for array calculations, and QUERY is ideal for advanced data analysis.
Frequently Asked Questions
Can I sum if checkbox is unchecked?
Yes, simply change the criterion to FALSE. For example, =SUMIF(A2:A10, FALSE, B2:B10) sums all amounts where the checkbox is unchecked.
Why is my SUMIF returning 0 even though checkboxes are checked?
Check that the checkbox cells actually contain TRUE. If you typed the word “TRUE” as text, it may not match. Also verify that the sum range is correct and that the numbers are stored as numbers, not text. Use =ISNUMBER(B2) to test.
Can I use a checkbox to toggle a sum on and off?
Absolutely. Put a checkbox in a cell, say D1, and use it as a master switch. For example, =IF(D1=TRUE, SUM(B2:B10), 0) returns the sum only when D1 is checked. Or use it in SUMIF: =SUMIF(A2:A10, D1, B2:B10) will sum when D1 is TRUE and ignore when FALSE.
Does SUMIF work with checkboxes in Excel?
Excel does not have a native checkbox control in cells like Google Sheets does. In Excel, you would use form controls or ActiveX checkboxes, which link to a cell that shows TRUE/FALSE. The same SUMIF logic applies, but you must first link the checkbox to a cell (right-click > Format Control > Cell link).
How do I count checked checkboxes instead of summing?
Use COUNTIF: =COUNTIF(A2:A10, TRUE) returns the number of checked checkboxes. If you want to count rows where a checkbox is checked and another condition is met, use COUNTIFS.
Can I sum only visible rows after filtering with checkboxes?
Yes, use the SUBTOTAL function with function number 109 (SUM) or 9 (SUM, but ignores hidden rows only when used with filters). For example, =SUBTOTAL(109, B2:B10) sums only visible rows. However, this does not directly consider checkboxes; you would need to filter by the checkbox column (showing only TRUE rows) and then use SUBTOTAL.
Practical Example: Expense Tracker
Imagine you have a simple expense tracker:
- Column A: Checkbox (checked means “paid”)
- Column B: Expense description
- Column C: Amount
To see how much you have paid, use =SUMIF(A2:A100, TRUE, C2:C100). To see unpaid, use =SUMIF(A2:A100, FALSE, C2:C100). To get a grand total, use =SUM(C2:C100).
You can also add a summary cell that shows the percentage paid: =SUMIF(A2:A100, TRUE, C2:C100) / SUM(C2:C100) and format it as a percentage. This gives you a quick financial overview without any manual counting.