Excel - COUNTIF and SUMIF across multiple rows - excel

I have a sheet with multiple columns of "Yes" / "No". I need to count the number of rows that have >5 "Yes". Obviously determining if an individual row should be included is easy using countif, but I can't figure out how to make the row 'eligible to be counted' and then sum the number of rows that meet my criteria.

Assuming your range is A2:Z100 this array formula will count the number of rows with 5 or more "Yes" entries
=SUM((MMULT((A2:Z100="Yes")+0,TRANSPOSE(COLUMN(A2:Z100)^0))>=5)+0)
confirm with CTRL+SHIFT+ENTER
or you can use this version with FREQUENCY
=SUM(IF(FREQUENCY(IF(A2:Z100="Yes",ROW(A2:Z100)),ROW(A2:Z100))>=5,1))
....which also needs "array entry"
or a third approach with COUNTIF - doesn't need array entry
=SUMPRODUCT(0+(COUNTIF(OFFSET(A2:Z100,ROW(A2:A100)-ROW(A2),0,1),"Yes")>=5))

Related

How to calculate how many text cells are same in row before (or chosen row)

I am doing some excel staff, and now need an formula to calculate how many is same and mark them.
Example i have row with 10 cells and want to compare with row under how many same cells are.
I marked same fileds but i need formula which takes range F15:O15 and compare with range F6:O6 to check how many same in these cells.
Let's say your data is like this:
As you can see, only 3 cells are identical in both rows (range D4:F4 = range D5:F5)
The formula I've used in cell D8is:
=SUMPRODUCT(--(A1:J1=A2:J2))
And it returns 3 :)

Countifs does not work when a range with multiple column is selected

I need a count if function that counts me the cells that meet a certain criteria. This should be done with countifs. The formula is the following:
=COUNTIFS(Orders!D:D;"*Ecolab*";Orders!B:B;">=01/01/2019";Orders!U:U;">=36";Orders!K:Q;">=1")This formula returns me an value type error.
This formula works well until I introduce the last condition orders!K:Q;">=1"
I would like a formula that counts if the word Ecolab is present in the cell; if the date is after or equal 01/01/2019; if the column U has more or equal than the number 36 and if there is at least a "1" in the cells in the row from column K to column Q. I could do this by easily replicating the countifs several times, (i.e =COUNTIFS(Orders!D:D;"*Ecolab*";Orders!B:B;">=01/01/2019";Orders!U:U;">=36";Orders!K:K;">=1")+COUNTIFS(Orders!D:D;"*Ecolab*";Orders!B:B;">=01/01/2019";Orders!U:U;">=36";Orders!L:L;">=1")+...........+COUNTIFS(Orders!D:D;"*Ecolab*";Orders!B:B;">=01/01/2019";Orders!U:U;">=36";Orders!Q:Q;">=1")
But I would rather not include such a long formula as it would create confusion for the ultimate user of the excel sheet
Per my comment above, you could use SUMPRODUCT (avoid using whole columns for that) or an array with OFFSET like this:
=SUM(COUNTIFS(Orders!D:D;"*Ecolab*";Orders!B:B;">=01/01/2019";Orders!U:U;">=36";OFFSET(Orders!J:J;0;{1;2;3;4;5;6;7});">=1"))
If the count for K:Q should be 1 when there may be more than one cell greater or equal to 1 in a single row then you need to apply OR criteria in a SUMPRODUCT.
SUMPRODUCT formulas should not use full column references; there is too much wasted calculation. The following is for rows 2:99; adjust for your own use.
=SUMPRODUCT(--ISNUMBER(SEARCH("ecolab", Orders!D2:D99)),
--(Orders!B2:B99>=DATE(2019, 1, 1)),
--(Orders!U2:U99>=36),
SIGN((Orders!K2:K99>=1)+(Orders!L2:L99>=1)+(Orders!M2:M99>=1)+(Orders!N2:N99>=1)+(Orders!O2:O99>=1)+(Orders!P2:P99>=1)+(Orders!Q2:Q99>=1)))

Count unique values in a column with blanks for each row in excel

I have a column of data (shown below) that I want to count each unique value in this list. I used this formula:
SUMPRODUCT((B2:B11540<>"")/COUNTIF(B2:B11540,B2:B11540&""))
However it gives me the entire count of unique ids and I want to count per row. Also, since this column has lot's of blank fields I am not able to count for each row using CountIf. Ideally the blank rows should give 0 and other duplicates should be counted as 1. Does anyone has a way of solving this?
A-2019-000084
A-2019-000141
A-2019-002944
A-2019-000222
A-2019-000222
A-2019-000222
A-2019-000222
A-2019-004606
A-2019-004606
A-2019-000923
A-2019-000699
use COUNTIF with a variable range:
=--AND(A1<>"",COUNTIF($A$1:A1,A1)=1)
For a total unique non-blank count of your sample data in column A use,
=SUMPRODUCT((A2:A23<>"")/(COUNTIFS(A2:A23,A2:A23,A2:A23,"<>")+NOT(SIGN(LEN(A2:A23)))))
For a row-by-row count, (with the first A-2019-000084 in A2) use this in B2 and drag down.
=--(COUNTIFS(A$2:A2, A2, A$2:A2,"<>")=1)

Merge data from several columns in pivot

I need to count how many times a given input data is found in four different columns and summarize that in a pivot table. There are other columns in the data table that I also want to be able to track in the pivot table. How can I easiest count the number of entries, such as pictured in the attached?
Columns MQ?
/E
Here are a number of ways to count cells in Excel:
Cell Counting Techniques
Excel provides many ways to count cells in a range that meet various
criteria:
The DCOUNT function. The data must be set up in a table, and a separate criterion range is required.
The COUNT function. Simply counts the number of cells in a range that contain a number.
The COUNTA function. Counts the number of non-empty cells in a range.
The COUNTBLANK function. Counts the number of empty cells in a range.
The COUNTIF function. Very flexible, but often not quite flexible enough.
An array formula. Useful when the other techniques won't work.
Formula Examples
Listed below are some formula examples that demonstrate various
counting techniques. These formula all use a range named data.
To count the number of cells that contain a negative number:
=COUNTIF(data,"<0")
To count the number of cells that contain the word "yes" (not case
sensitive):
=COUNTIF(data,"yes")
To count the number of cells that contain any text:
=COUNTIF(data,"*")
To count the number of cells that contain text that begins with the
letter "s" (not case-sensitive):
=COUNTIF(data,"s*")
To count the number of cells that contain the letter "s" (not
case-sensitive):
=COUNTIF(data,"*s*")
To count the number of cells that contain either "yes" or "no" (not
case-sensitive):
=COUNTIF(data,"yes")+COUNTIF(data,"no")
To count the number of three-letter words:
=COUNTIF(data,"???")
To count the number of cells that contain a value between 1 and 10:
=COUNTIF(data,">=1")-COUNTIF(data,">10")
To count the number of unique numeric values (ignores text entries):
=SUM(IF(FREQUENCY(data,data)>0,1,0))
To count the number of cells that contain an error value (this is an
array formula, entered with Ctrl+Shift+Enter):
=SUM(IF(ISERR(data),1,0))
Source: spreadsheetpage.com: Cell Counting Techniques

How do I only count visible (filtered) rows when using the COUNTIFS function? [duplicate]

I've been using Excel's COUNTIFS function to count the number of rows in a table that meet certain criteria, E.g:
=COUNTIFS(Table1[Result],"Fail", Table1[Comments], "")
Now I want to modify this expression so that it only counts rows in Table1 that are visible. (I.E. Not filtered out.) How can I accomplish this?
Simple way is to add another column to table - e.g. called helper with a formula like this
=SUBTOTAL(103, B2)
where column B is Result column
Now change formula to
=COUNTIFS(Table1[Result],"Fail", Table1[Comments], "",Table1[Helper],1)
the subtotal formula only returns 1 on visible rows
Without a helper column you can use this formula
=SUMPRODUCT((Table1[Result]="Fail")*(Table1[Comments]=""),SUBTOTAL(103,OFFSET(Table1[Result],ROW(Table1[Result])-MIN(ROW(Table1[Result])),0,1,1)))
I use this formula:
=subtotal(3,B2:B100)
where subtotal(3, that is CountA and
B2:b100 is the range.
The hidden rows in a filter are ignored and this formula only counts the visible rows.
It works for me and hope it works for you

Resources