سؤال

Here is the situation I'm having in a Google spreadsheet:

Spreadsheet

I need to sum up every second cell in the yellow line (look at the picture) not including those ones which are below the statement FALSE in the red line. Those statements are written in two merged cells if it has any importance in solving this problem. In this example, the right numbers should be: 4.00, 4.00, 8.00 with 16.00 as a final answer.

I did some research in various Excel forums and found out this line should do the trick for summing up every second cell in a single column beginning with B3 cell:

= SUM(IF(MOD(ROW($B$3:$B$22) - ROW($B$3) + 1, 2) = 0, $B$3:B$22, 0))

I adjusted this to my situation (for the moment ignoring the fact about TRUE-FALSE check):

= SUM(IF(MOD(COLUMN($E$6:$N$6) - COLUMN($E$6) + 1, 2)=0, $E$6:N$6, 0))

Unfortunately, it is not working for me in a Google spreadsheet. Finally, I came up with formula which is working corectly for this purpose:

  = SUM(IF($E$2 = "TRUE", $F6, 0), IF($G$2 = "TRUE", $H6, 0), IF($I$2 = "TRUE", $J6, 0), IF($K$2 = "TRUE", $L6, 0), IF($M$2 = "TRUE", $N6, 0))

The problem is that constructing the formula this way is going to make it extremely long and way too inconvenient (as hundreds of columns are going to be added on the left)

Any suggestions?

هل كانت مفيدة؟

المحلول

This would be easy to solve if you used a column to do the logic breakout.

For example, In column 7 put the following two formulas:

E7:

=if(E2="TRUE",E6,0)

F7:

=if(E2"TRUE",E7,0)

Then you can just SUM this row of tests.

Unfortunately Google Doc's formulas are not always as advanced as Excel's so sometimes you must do workarounds to make things possible.

That being said... If you really want an All-In-One Formula solution for google docs... try this:

=SUMIF(E2:N2,"TRUE",E6:N6)+SUMIF(E2:N2,"TRUE",F6:N6)

The magic happens in the second SUMIF, Note that it starts with F6 thus offputting the sum-array by 1. To implement just change the letter "N" in the formula with your last column in the sheet.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top