问题
So I am getting data fed into a spreadsheet on Google Sheets. I cannot edit that spreadsheet.
I have an additional sheet in the document that totals up the columns in this sheet. The sheet received info such as:
A B C D This info is not actually in the sheet
|------------| \/ \/
| 4 1 0 0 | <-- Valid
| 3 1 1 0 | <-- Valid
| 3 1 0 2 | <-- Invalid
| 3 0 1 1 | <-- Valid
|------------|
The total of each individual row should be 5, but I do not currently have a way of validating this in the form itself. So I need to disregard or remove the data if it is in violation.
So basically, I want to add all the values of column A together, but only of the rows in which the total of these 4 cells are exactly 5; No more, no less.
The furthest/closest I have gotten was using SUMIF, but the I need a single cell indicating whether or not the row totals up to 5, and as I said before, I cannot edit the cells in that specific sheet.
回答1:
Try this:
=SUMPRODUCT((($A$1:$A$4+$B$1:$B$4+$C$1:$C$4+$D$1:$D$4)=5)*$A$1:$A$4)
来源:https://stackoverflow.com/questions/35991604/only-add-cells-in-column-when-the-total-of-multiple-other-cells-in-that-row-equa