I am hoping to calculate a total as is grows or decreases using only 1 row and only 2 cells in this row. I'm wondering if it this is even possible with a formula (not a script):
Scenerio:
A1 and A2 have a Value of 0
(A2 is the running total of A1, whenever a number is entered into A1 and Enter is pressed, this number will add to the value of A2)
A1 has 2 entered into it and Enter is press (Cell changed)
A2 adds this to its 0, becoming 2.
A1's 2 is deleted, but A2 remains 2.
A1 has 3 entered into it and Enter is press (Cell changed)
A2 becomes 5
(The only way to add or subtract from A2 is enter - or + number into A1, otherwise A2 remains the current total)
I hope this is clear. I would like all things isolated to a single row, so a normal running total does not work for this case.
To be able to accomplish this task you will need to adjust your Spreadsheet settings.
For your specific case scenario where you just want to add (or subtract) only once the value of A1 to A2 you would need to head over your Spreadsheet menu bar and select File->Spreadsheet Settings-> Calculation. In that tab you should turn on Iterative calculation and set the Recalculation to on Change and the Maximum number of iterations to 1 .
Finally set A2 formula to be = A1 + A2. Every time you change A1 its value will be added (or subtracted if it is a negative value) to A2.
Reference
Choose how often formulas should recalculate
Related
I have a sheet that has blocks of cells. I add them for a total if they don't contain any letter. Letters signify a specific variable or signifier code for tracking. I also want to add the cell value when a cell has an ending code letter. I've tried SUMIF, Substitute, SumProduct and a few others.
For a while I've used the following which worked till the S value changed to another number than "8" which then gave the wrong sum from the range.
=if(countif(D64:Q64,"*S")=0,"",((countif(D64:Q64,"*S"))*8))
In the cell range I have 5 variable groups ending in a letter (A, H, S, C and R) and one group not ending in any letter.
The formula I use to add the cells not containing a letter but have a value is this
=IF(SUM(AA64,(SUMIF(D65:Q65,"<>")),-(COUNTIF(D65:Q65,">=0")*8))>24,24,(SUM(AA64,(SUMIF(D65:Q65,"<>")),-(COUNTIF(D65:Q65,">=0")*8))))
which adds the table data plus the previous lines table data but does not exceed 24.
H is a set value of 6 and doesn't change.
Does anyone know how to add the value of the cells that contain a specific letter?
N (number)
A
S
C
R
H
8.5
H
8A
2S
9
3C
0.5R
17.5
8
2
3
0.5
6
I'd prefer it be a formula usable in Google Sheets because that is where this data is.
Solution:
You can use this formula below column "N" then drag right until below column "H".
=SWITCH(H$1,"N",SUM($A2:$G2),"H",6,SUM(IFERROR(ARRAYFORMULA(VALUE(LEFT($A2:$G2,FIND(H$1,$A2:$G2)-1))),0)))
This is a combination of three formulas:
If the row above is N, sum A2 to G2. This will ignore all the strings.
If the row above is H, output 6.
Else, get the number to the left of the defined suffix, set all others to 0, and get the sum.
Output:
References:
Extract number from string in Google Sheets
An alternative could be to use
=SUMPRODUCT(A3:G3, isnumber(A3:G3))
to compute the sum of the cells with numbers only, and to use
=sum(filter(substitute($A$3:$G$3, I$2,)+0, regexmatch($A$3:$G$3, I$2)))
under the 'A' and drag to the right
Examples
I have this table and I want B1 and B2 to display the sum where D1, F1 and H1, and D2, F2 and H2 are bigger than 0, respectively. I will be inserting two columns to the left of C on a regular basis, and I don't want the column references in the formula to be updated when the columns are shifted, but if B2 becomes B3 when a row is added above it, I will need the formula to be updated for the row and check the values in D3, F3 and H3, or if I add rows below it, I want to be able to drag down and get the formula copied with incremental row values. I tried INDIRECT with and without &CELL("address", E2) but I couldn't get it to work as I wanted it.
A B (Sum) C D E F G H
1 Josh 3 Some number 6 Some number 4 Some number 3
2 Fiona 2 Some number 1 Some number 0 Some number 4
You can use OFFSET to get absolute column references, and COUNTIF to count if each referenced cell is bigger than 0:
=COUNTIF(OFFSET(B1,0,2),">0")+COUNTIF(OFFSET(B1,0,4),">0")+COUNTIF(OFFSET(B1,0,6),">0")
Not perfect, but try =SUM(OFFSET(B2,0,1,1,500)). That way you refer to the cell itself so whenever you add columns it's not affected. I used 500 arbitrarily since it's simple. Adjust as needed.
I'm having an issue with google spreadsheets. I want to... have Cell C2 always contain the difference between cell E2 and F2 even if I move the row (i don't want the formula to adapt to that change of rows, the formula should still be E2-F2); so let's say E2 contains 5 and F2 contains 3, C2 would display 2. So let's say I switch row E and row F. Right now the result displayed would still be 2, and the formula in cell C2 would've changed to F2-E2. What I want is the formula not to change, and the result displayed would be -3.
=INDIRECT(E2)-INDIRECT(F2) didn't work for me - it gave me a reference error.
The INDIRECT function expects a string parameter. So you would need to write
=INDIRECT("E2")-INDIRECT("F2")
But the better way to solve your problem would be to use absolute references
=$E$2-$F$2
I need to add the total of every 3 rows.... so I need total of rows 1- 3 then total of 4-6 then total of 7-9 and so on and need to do this for over 400 rows...
Assuming the data you wish to sum is in Column A and the summed data will be in Column B (with headers for both columns) you can do the following:
On B4 enter =SUM(A2:A4)
Then select B2:B4 and drag to copy the contents down your range of data.
This will give you the sum of every three rows.
Assuming the list starts at A1, you can use the following starting at B3 and carrying it down the list. Then set B1 and B2 to 0 and filter out all zeros.
=IF(MOD(ROW(),3)=0,SUM(A1,A2,A3),0)
This determines if the row number is divisible evenly by 3, if it is it returns the sum of that row and the previous 2, otherwise it returns zero.
If you have a header row, you can change it to and set zeros for B2 and B3 and start this on B4
=IF(MOD(ROW()-1,3)=0,SUM(A2,A3,A4),0)
I want to compare two cells and obtain a percentage, for instance:
A1 is 190
B1 is 200
C1 is the answer
I tried:
B1 >= A1
but the answer is TRUE.
I will create a report if cell B1 s greater than cell A1 then:
IF YES I need to get the 12% percent of cell B1 and the answer would appear on cell C1
IF NOT the value for cell C1 would be 0.00.
Can anyone help me to create a syntax for that?
Try =IF(B1>=A1,B1*0.12,0)
check snap below
And for formatting you can select column, right click - Format Cells - select Number and keep 2 Decimal places.