Distinct Count Ifs Formula

madab

New Member
Joined
Jan 29, 2014
Messages
27
Hi,

Have started using Sumifs and Countifs formulas recently and have found quite useful. When using Coutifs formula though, is there a Distinct Count version?

I have a data set that contains a list of people but some may appear multiple times. Each person has a unique identifier and I can't remove the multiple lines, I need to keep them in the data.

I want to be able to count how many people have a specific set of conditions within the data. I can use Countifs formula but that doesn't get around the individuals appearing more than once and is throwing off calculations when trying to work out averages.

Any advise much appreciated!
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Eric W

MrExcel MVP
Joined
Aug 18, 2015
Messages
12,639
COUNTIFS can't count unique instances, but there are other options.

Could you provide a small sample of your table, and explain what conditions you want to check, and what results you want to see? You can possibly use the HTML Maker link in my signature to show a table.
 
Upvote 0

madab

New Member
Joined
Jan 29, 2014
Messages
27
Hi Eric,

Table below is a bit simplified but I think the logic is the same ....

Id Age Colour
1 25 Red
2 26 Blue
3 25 Red
1 25 Red
4 26 Yellow

I want to count the number of Id's that are 25 and Red. I think Countif would give me 3 but there are only 2 because Id 1 appears twice in the table. Does that make sense?
 
Upvote 0

James006

Well-known Member
Joined
Apr 4, 2009
Messages
4,600
Office Version
  1. 2016
Platform
  1. Windows
Hi,

You can test the following formula
Code:
=SUMPRODUCT((B2:B6=25)*(C2:C6="Red"))

HTH
 
Upvote 0

Canapone

Active Member
Joined
May 10, 2007
Messages
463
Hi



Code:
=SUM(IF(FREQUENCY(IF(C2:C6="Red",IF(B2:B6=25,A2:A6)),A2:A6),1))

to be confirmed with control+shift+enter

Regards
 
Upvote 0

Eric W

MrExcel MVP
Joined
Aug 18, 2015
Messages
12,639
Canapone's formula is pretty much ideal if the ID values in column A are numeric. If they are alphanumeric, try:

=SUM(IF(FREQUENCY(IF(C2:C6="Red",IF(B2:B6=25,MATCH(A2:A6,A2:A6,0))),ROW(A2:A6)-ROW(A2)+1),1))
 
Upvote 0

Forum statistics

Threads
1,191,697
Messages
5,988,163
Members
440,131
Latest member
EricMoz

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
Top