New Contributor

# Counting Rows based on certain variable combinations

Hopefully my question is clear, and I hope the attachment shows up.

I have a large spreadsheet with about a dozen columns of information. I would like to count how many rows have certain cells that have specific values in them.

My querying is much more extensive than what COUNTIFS can return and the various SUMPRODUCT arguments I've tried aren't cutting it either.

Given 8 columns of data (after the column uniquely identifying each item being characterized by the data), and each cell being possibly only 1 of 2 values, there are 256 different unique combinations of values in a given spreadsheet. Long story short, there are also 6560 unique ways of quantifying the items based on the characteristics - ranging from returning quantities based on all 8 cells associated with each data point or on only a few cells or even just one cell.

My spreadsheet has thousands of rows of these combinations. Now, barring creating a COUNTIFS for each cell combination, which would be time-prohibitive to say the least, I was wondering if there was a formula short cut for this.

Let me attach a slightly more intense example spreadsheet (hopefully without violating the forum guidelines).

In hypothetical2, on the right side where I'm building my analysis spreadsheet, in some instances I'm concerned with combinations based on only a handful of cell's data, and in some instances I'm concerned with all the cells, and in some only a few cells. Now, as alluded to before, with 8 columns, each column showing 1 of 2 variables...there could be up to 6560 different ways to count the items if the items are counted considering all the cell's or only a handful of the cells associated with each item.

I hope I am not muddying the issue, and if Excel doesn't have a formula or a combination of formulas to handle that task, I'll just live with it. I've just wracked my excel-novice brain for what combination of nested formulas might solve my problem.

Thanks!

2 Replies

# Re: Counting Rows based on certain variable combinations

I think this is the solution, using wildcards:

=COUNTIFS(B:B,IF(L3>0,L3,"*"),C:C,IF(M3>0,M3,"*"),D:D,IF(N3>0,N3,"*"),E:E,IF(O3>0,O3,"*"),F:F,IF(P3>0,P3,"*"),G:G,IF(Q3>0,Q3,"*"),H:H,IF(R3>0,R3,"*"),I:I,IF(S3>0,S3,"*"))

# Re: Counting Rows based on certain variable combinations

As variant

here

``=SUMPRODUCT(--(MMULT(--((\$B\$3:\$I\$100=\$L3:\$S3)+(\$L3:\$S3="")),{1;1;1;1;1;1;1;1})=8))``