Use ARRAYFORMULA with horizontal COUNTIF - google-sheets

I am using COUNTIF to count the number of occurrences of a value in a horizontal range, which is working fine:
Now I would like to use ARRAYFORMULA to automatically apply that logic to an entire column. My problem is that ARRAYFORMULA doesn't seem to work well with COUNTIF as my range spans both horizontally and vertically. I tried several things:
=ARRAYFORMULA(IF(COUNTIF(B2:D,"Passed")=3,"Passed","Failed")) : the formula doesn't even replicate across the column
=ARRAYFORMULA(IF(ISBLANK(B2:B),"",IF(COUNTIF(B2:D,"Passed")=3,"Passed","Failed"))) : using the extra IF(ISBLANK(B2:B) trick solves the above issue, but the results are wrong
How can I apply ARRAYFORMULA to a formula containing a horizontal COUNTIF?
Here is a link to the spreadsheet if you want to play around

An alternative:
=if(arrayformula(len(B2:B)*(B2:B="P")*(C2:C="P")*(D2:D="P")),"Passed","Failed")

Related

Google Sheets - Combining COUNTBACKGROUNDCOLOR and COUNTIF formulas

I want to count the amount a certain text(aus) appears in a column, but I only want to search the rows that have one specific color. I have the two seperate working formulas but haven't been able to combine them succesfully yet. Anybody an idea how to do this :) ? Here are the 2 formulas i have:
=COUNTBACKGROUNDCOLOR("J2:J361";"A2")
=COUNTIF(J2:J361; "*aus")
It appears as though you are using a script to implement your own function of COUNTBACKGROUNDCOLOR(). If this is the case you cannot combine the two functions as it stands since it is a user defined function. As MattKing pointed out maybe count the cells with your data AND the method used to declare the color (checkboxes). Example:
Conditional formatting applied to cells that highlight the cell green if adjacent checkbox is TRUE.
Formula used
Notice the answer is 2 and not 3 because from your formula you are only looking for wildcards before "aus" and Cell D4 contains a "?" at the END ("what is aus?")

Array formula for countifs to propagate down the rows (only for rows with data in column A)

I am new to google app sheet formulas.
In the image attached i have highlighted the formula, it works.
The formula i am using is =COUNTIFS(D4:S4,"y",D3:S3,"Personal")
Now i want to propagate this using ARRAYFORMULA for rows 5 and 6.
I tried with the below formula
=ArrayFormula(if(len(A2:A),COUNTIFS(D4:S,"y",D3:S3,"Personal"))
--Update
After adding the formula provided by Matt i am getting count mismatch for one row
--Update #2
As suggested by Eric, i found a space in the Header row
Unfortunately, it's not quite that straightforward to populate a COUNTIFS that reads sideways like that in the down direction. The common way to do this is with a function called MMULT() which does "matrix multiplication" but is very good for adding or counting across a 2d range like that. In your case because it's dates going sideways, i'm going to assume that the sheet keeps growing to the right? All the way across indefinitely?
You might try this in cell B4:
=ARRAYFORMULA(IF(A4:A="",,MMULT(N(OFFSET(D4,,,9^9,9^9)="Y"),TRANSPOSE(N(D3:3="Personal")))))
You can check out this MMULT() demo sheet I made a while back.

Dynamic formula which Sums the Value if criteria is met

I have been working on sheet where i always apply SUM manual by selecting the each cell separately.
There are multiple sheets where i SUM manually with similar headers that are available in Col"A".
I just want to make SUM formula dynamic.
when it will become dynamic i will drag it from left to right and formula will give SUM result.
I have tried with IF but could not make it and i am sure its not just IF that could make it.
use:
=SUM(FILTER(B5:B, REGEXMATCH($A5:$A, TEXTJOIN("|", 1, $L2:$L))))

Sum of cells containing a formula in google sheets

I want the sum of values in a column. However I wish to ignore cells which do not contain a formula. I tried
=SUMIF(A1:A10, ISFORMULA(A1:A10))
But that did not work
if its a small range you can do:
=SUM(FILTER(A1:A10, {ISFORMULA(A1); ISFORMULA(A2); ISFORMULA(A3);
ISFORMULA(A4); ISFORMULA(A5); ISFORMULA(A6);
ISFORMULA(A7); ISFORMULA(A8); ISFORMULA(A9); ISFORMULA(A10)})
This way might work for you.
I added a column with the following formula, which unfortunately also doesn't work as an arrayformula. But if you put this at the top of your column, beside the one you want to sum, and double click the "drag down" blue square on the bottom right corner of the cell, it will fill all the way down, provided you have no blank rows. Dragging down also works obviously.
=IFNA(FORMULATEXT(A1),0)
This creates a column of zeroes and text formulas, which you can use as a filter for your SUMIF formula, as follows: (assumes data column is A1:A30, helper column is B1:B30. SUMIF is in C1)
=SUMIF(B1:B30,"=0",A1:A30)
Let me know if this is useful, or not.

Google Sheets CountIFS

I have a Google spreadsheet that I am trying to count scores of 1 to 5. I can do a COUNTIF to count the number of 5s, 4s, 3s, etc.
I need to count the the values separately depending if the value of the first row begins with a space or not. The COUNTIFS formula will not work, since the arrays are the same size.
My formulas are:
With space:
=COUNTIFS(B1:F1,=" *",B2:F5,"=5")
Without space:
=COUNTIFS(B1:F1,="<> ",B2:F5,"=5")
Here is a sample of my spreadsheet: https://docs.google.com/spreadsheets/d/1xmEpTgBKDh-ZuLuxijbqAwx4nRKrThv5LnTI5TgP5XI/edit?usp=sharing
I have several forms and the number of cells that begin with a space varies per sheet and I rather create a formula that works for all of them.
Is there another option I can use other than COUNTIFS?
Try something like
=countif(filter(B2:F5, regexmatch(B1:F1, "^\s")), "=4")
and see if that works?
And for the header rows that do not start with a space
=countif(filter(B2:F5, left(B1:F1, 1)<>" "), "=3")

Resources