COUNTIFS with row/column ranges and duplicates

zyangacp

New Member
Joined
Sep 12, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Picture1.png

Picture2.png

Hi, trying to write a formula using data in the first table to populate the second table, counting unique non-zero occurrences. Meaning, criteria for D3 in the second table would be:
- All columns in the first table matching B3 in the second table (so, columns D, E, F, G, H if I'm counting manually)
- All rows in the first table matching D2 in the second table (Row 6 and 15)
- All values >0 (D6, D15, E15, F15, G15, H15)

So, value of D3 should = 6. I'm trying to use a combination of COUNTIFS and INDEX/MATCH but can't seem to get there. Any help appreciated, thanks!!
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Welcome to Mr Excel, @zyangacp (y)

Could you just clarify the expected result please? You mention in the first line that you want to count unique non-zero occurrences, which looks (to me) to give a result of 5 for the example given (D6, D15, E15, F15, G15, H15) because F15 and G15 are identical.

Is that what is required, or am I simply overthinking that part of the question?
 
Upvote 0
Following up on my reply with a couple of formulas because I'm not going to be online for much longer today.

For a result of 6 as per your example.
Excel Formula:
=SUMPRODUCT((Sheet1!$D$1:$H$1=$B3)*(Sheet1!$C$2:$C$18=C$2)*(Sheet1!$D$2:$H$18>0))
For a result of 5 as per my interpretation of the unique count requirement.
Excel Formula:
=SUMPRODUCT(--(FREQUENCY(IF((Sheet1!$D$1:$H$1=$B3)*(Sheet1!$C$2:$C$18=C$2)*(Sheet1!$D$2:$H$18>0),Sheet1!$D$2:$H$18),Sheet1!$D$2:$H$18)>0))
In both formulas, Sheet1 refers to the table in the top screen capture shown in your original post.

Hopefully that will give you what you need.
 
Upvote 0

Forum statistics

Threads
1,215,669
Messages
6,126,111
Members
449,292
Latest member
Mario BR

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top