How to ignore text/strings in google sheet Sum calculation? - google-sheets

If I have a Text in a sum calculation which I would like to ignore. On the picture below you can see my formula. The text OFF is throwing an error on total hours for me. Any help is appreciated.

Your SUM function is pointless the way you have written it as you're already calculating the result with + and - operators (which is why you get the error). Try:
=SUM(C4,E4,G4,I4,K4,M4,O4)-SUM(B4,D4,F4,H4,J4,L4,N4)

Another approach:
=SUMIF(B3:O3,"End",B4:O4)-SUMIF(B3:O3,"Start",B4:O4)

Related

How to find out sum of multiplication of 2 column based on value of a third column?

Silly Q, plz help
I am trying to find of Total invested amount for open positions in my PF. which is like
sum( if(G3="","",D3xE3)+if(G4="","",D4xE4)+..+.........)
How to write a formula for the same.
Thanks.
Try SUMPRODUCT() like-
=SUMPRODUCT(D3:D100,E3:E100,G3:G100="")

How to use arrayformula in googlesheet to count the column with condition?

Hi everyone,
I'm trying to count the number of "Yes" appeared in each row. I want to use array formula so that I'm not required to have formula in each cell in column G. May I know arrayformula can achieve this or there is other method? I tried to use arrayformula(countif(B4:F4,"Yes")) but nothing come out for row 5,6,7,8. Hope to get some advice on this problem as I'm new to google sheet. Thank you.
Give this a try.
=ARRAYFORMULA(COUNTIF(IF(B4:F="Yes", ROW(B4:B8)), ROW(B4:B8)))
Edit: For the case that you describe below (only including certain columns), it's a little more involved, but the same principle works.
=ARRAYFORMULA(COUNTIF(IF(B4:B="Yes", ROW(B4:B8)), ROW(B4:B8)) + COUNTIF(IF(D4:D="Yes", ROW(D4:D8)), ROW(D4:D8)) + COUNTIF(IF(F4:F="Yes", ROW(F4:F8)), ROW(F4:F8)))

Formula that will skip one column when calculating SUM() or similar functions

I'd like to run a =SUM(A1:G1), but always skip one column, regardless if it has value or not.
In this case, it should calculate A1+C1+E1+G1.
Is there another function I could append to SUM() or other similar functions as SUM in order to skip one column?
Thank you!
Using the following method you can calculate any number of alternate columns, without the need of manual +
Suppose your data is in second row onwards, use this formula
=SUMPRODUCT(A2:G2, MOD(COLUMN(A2:G2),2))
Simply a sumproduct of cell values and a array of {1,0,1,0,1...}
Another slight variation
=SUMPRODUCT(A2:G2*ISODD(COLUMN(A2:G2)))
But if the even columns contain letters instead of numbers this will give an error, so you can use instead
=SUMPRODUCT(N(+A1:G1)*ISODD(COLUMN(A1:G1)))
Comparing #AnilGoyal's answer, this works as well
=SUMPRODUCT(A1:G1,--ISODD(COLUMN(A1:G1)))
You can use:
=SUM(INDEX(A1:G1,N(IF(1,{1,3,5,7}))))
Or with Excel O365:
=SUM(INDEX(A1:G1,{1,3,5,7}))
A bit more of a general solution:
=SUMPRODUCT(MOD(COLUMN(A1:G1),2)*A1:G1)
Or with Excel O365:
=SUM(MOD(COLUMN(A1:G1),2)*A1:G1)
Or even:
=SUM(INDEX(1:1,SEQUENCE(4,,1,2)))
Since you included Google-Sheets, I'll throw in an option using QUERY():
=SUM(QUERY(TRANSPOSE(1:1),"Select * skipping 2"))
Maybe a bit more verbose, but very understandable IMO.
Consider something of the format:
=SUM(A1:G1)-INDEX(A1:G1,2)
The 2 in the formula means remove the 2nd item in the part of the row. (so the 999 is dropped)
So the formula =SUM(BZ10:ZZ10)-INDEX(BZ10:ZZ10,2) drops CA10 from the sum, etc.(a similar formula can be constructed for columns)
google sheets:
=INDEX(MMULT(N(A1:H3), 1*ISODD(SEQUENCE(COLUMNS(A:H)))))
=INDEX(IF(ISODD(COLUMN(A:H)), TRANSPOSE(MMULT(TRANSPOSE(
IFERROR(A1:H3*ISODD(COLUMN(A:H)), 0)), 1^ROW(A1:A3))), ))

Arrayformula Running Total with multiple columns

I've got the following task to solve, but I can't wrap my head around it.
There are a couple of numbers for different years. I would like to have a running total sum of all columns (= range C:I) in column J. I can do that with a formula in every cell of J - however I need to achieve it with a single arrayformula in J2.
What i figured after a lot of research are 2 steps:
replace empty cells with 0s, since arrayformulas obviously have some problems with empty cells
make a sum of each row
For step 1 the formula is: =ARRAYFORMULA(IF(ISBLANK(C2:I15),0,C2:I15)) which gives me back a temporary array like:
As this is a 15x7 array, I need something like a 7x1 array to multiply with in order to get a 15x1 array.
That formula would be: =ARRAYFORMULA(TRANSPOSE(COLUMN(C1:I1)^0))
So in the end my formula so far look like: =ARRAYFORMULA(MMULT(IF(ISBLANK(C2:I15),0,C2:I15),TRANSPOSE(COLUMN(C1:I1)^0)))
And this results in a 15x1 array that gives me the sum per row, but not a total running sum of all rows.
This is where I am stuck - any help and ideas are greatly appreciated.
EDIT: added a shared version for you to fiddle: https://docs.google.com/spreadsheets/d/1cqNEsWHqBaHdDrMY8x4DUKpEkYprRZ8AibEe7d0knPY/edit?usp=sharing
I think this will work too:
=ARRAYFORMULA(IF(B2:B="";;SUMIF(SEQUENCE(ROWS(C2:I);COLUMNS(C2:I));"<="&SEQUENCE(ROWS(C2:I);1;COLUMNS(C2:I);COLUMNS(C2:I));C2:I)))
try:
=ARRAYFORMULA(IF(B2:B="";;MMULT(TRANSPOSE((ROW(M2:M)<=TRANSPOSE(ROW(M2:M)))*
MMULT(C2:I*1; ROW(A1:A7)^0)); SIGN(MMULT(C2:I*1; ROW(A1:A7)^0))^0)))

Count occurrences of given character in interval

I have an interval of data that seems like this:
I need to count how many Vs and how many Ds there are.
I already tryed with SUMIF and COUNTIF
Can someone help me?
Solution:
Join all the cells
Use Regex to replace everything other than the required character(ex.V) to null
Find the length of remaining string
Sample Formula:
=LEN(ARRAYFORMULA(REGEXREPLACE(JOIN(,A2:A9),"[^V]",)))
This Formula could also help. Just edit the range and letter according to the requirement here and you will get the exact number.
=ARRAYFORMULA(SUM(len(A$1:A)-len(SUBSTITUTE(A$1:A,"V",""))

Resources