Home > Blockchain >  Google Sheets - Using a sum formula and multiplying that sum depending on the status of checkboxes
Google Sheets - Using a sum formula and multiplying that sum depending on the status of checkboxes

Time:08-17

I'm just starting and trying to learn about google sheets and I've got a much more involved sheet than what I'm showing here, but essentially I have ten check boxes and those boxes are each given a unique value when checked. When not checked they are all 0.

In this image I have 10 boxes in column A, with their assigned ON values in column B. Column C1 has the =SUM formula.

What I'm trying to figure out is how to multiply the summed number if boxes 9 OR 10 are selected. So box 9 and 10 would still contribute their value for the sum function but then would also have a multiple value that is triggered for the summed total.

Thanks in advance for any help!!

edit: sorry, I think I've caused some confusion. The values in the B column are just a visual representation of the value of the assigned value of the check boxes themselves, they aren't actually necessary to be used, but I'll see if I can use any of the answers listed to logic my way through it! thanks! Image of sample sheet

CodePudding user response:

use:

=SUMPRODUCT(SUMIF(A1:A10, TRUE, B1:B10)*IF(A9=TRUE, B9, 1)*IF(A10=TRUE, B10, 1))

enter image description here

enter image description here

CodePudding user response:

Try this

=ArrayFormula(IFERROR(SUM(QUERY(VLOOKUP(
 QUERY(IF(A1:A<>TRUE,,ROW(A1:A)), "Select * Where Col1 is not null",0),
 QUERY({ROW(A1:A),B1:B}, "Select * Where Col1 is not null") ,2,0), " Select * where Col1 is not null "))*
 PRODUCT(QUERY(VLOOKUP(QUERY(IF(A1:A<>TRUE,,ROW(A1:A)), "Select * Where Col1 is not null",0),
 QUERY({ROW(A1:A),B1:B}, "Select * Where Col1 is not null") ,2,0), " Select * where Col1 is not null ")),""))

enter image description here

Test all checkboxes

enter image description here

  • Related