Count If with multiple criteria and unique values

dixon1983

Board Regular
Joined
Apr 23, 2005
Messages
175
Hi,
I dont know if this is possible or not but thought I'd ask anyway.

I have a sheet of data and want to run a count on the values in Column A with the following criteria:

- If the value in column B is repeated then the value in column A can only be counted once...
- Column C must equal 'M'.


Example:
A.....B.....C
1.....42....M
1.....42....M
2.....41....A
2.....41....M
1.....56....M


In this example 1 would be counted 2 times, and 2 would be counted once.

I have about 15 sheets of data like this and would like a master sheet to look into each sheet and give me a count of each so id prefer to not use the advanced filter => unique variables option if possible.

Any help would be greatly appreciated.

Dixon.
 
Oh, wow, a cake sounds nice!! :p

As far as learning Excel, I'm largely self taught. I have been a programmer for many years, and a lot of the principles I learned in class and on the job carry over. But mostly it's from digging in and experimenting. Actually, this is a great example. Go through my formula and Aladin's and try to understand how they work, and what the differences are. Aladin typically writes formulas that work for any data, while I might write a simpler formula if I believe the data won't have any specific issues. In this case I made 2 assumptions, that you wouldn't have a value in B if A was empty, and that since column A has companies and B has locations, you wouldn't need the "|". Which brings us back to Aladin's question: do you always need the "|"? Is it needed in this case? Should you put it in as a basic rule? These are some of the high level questions you might ask when designing a formula.

Just keep plugging away. The more you do, the more intuitive it becomes. If you have questions, feel free to come back and ask! :cool:
 
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hello,

This thread is amazing! I'm not sure if you've answered my excel question yet, (I read through about 20 pages before I decided to just ask). I'm trying to count unique values in column B (unduplicated count of individuals, so if someone's there twice they only get counted once) and then a separate count of how many of those unduplicated folks are from Jersey City, and then how many of those unduplicated folks are single. So basically, is there a way to generate a count of terms from columns C and D that solely reflect off the unduplicated/unique values in B? THANKS!

A B C D
03/03/16 Sam. H. Jersey CitySingle
Steve. M. Jersey CityMarried
Harold. R. KearnySingle
Harold. R. KearnySingle
03/04/16 Sherry. S.Jersey CityMarried
Calvin. B.Jersey CitySingle
Calvin. B.Jersey CitySingle
Nancy. R.Jersey CityMarried
Nancy. R.Jersey CitySingle
03/07/16 Sherry S.Jersey CityMarried
Kathy. H. Jersey CityMarried

<colgroup><col><col><col><col><col><col></colgroup><tbody>
</tbody>
 
Upvote 0
Ugh, my report pasted differently. Maybe this helps - without columns listed ABCD, but A is the date, B is the name, C is the city, D is single/married. You probably could've figured that out but I wanted to be clear. THANKS again!


03/03/16Sam. H.Jersey CitySingle
Steve. M.Jersey CityMarried
Harold. R.KearnySingle
Harold. R.KearnySingle
03/04/16Sherry. S.Jersey CityMarried
Calvin. B.Jersey CitySingle
Calvin. B.Jersey CitySingle
Nancy. R.Jersey CityMarried
Nancy. R.Jersey CitySingle
03/07/16Sherry S.Jersey CityMarried
Kathy. H.Jersey CityMarried

<tbody>
</tbody>
[/QUOTE]
 
Upvote 0
@Rriot

Row\Col
A​
B​
C​
D​
E​
1​
3/3/2016
Sam. H. Jersey City Single
2​
Steve. M. Jersey City Married unique individuals
3​
Harold. R. Kearny Single 8
4​
Harold. R. Kearny Single Jersey City
5​
3/4/2016
Sherry. S. Jersey City Married 7
6​
Calvin. B. Jersey City Single Single
7​
Calvin. B. Jersey City Single 4
8​
Nancy. R. Jersey City Married
9​
Nancy. R. Jersey City Single
10​
3/7/2016
Sherry S. Jersey City Married
11​
Kathy. H. Jersey City Married

In E3 control+shift+enter, not just enter:
Rich (BB code):
=SUM(IF(FREQUENCY(IF(1-($B$1:$B$11=""),MATCH($B$1:$B$11,$B$1:$B$11,0)),
    ROW($B$1:$B$11)-ROW($B$1)+1),1))
In E5 control+shift+enter, not just enter:
Rich (BB code):
=SUM(IF(FREQUENCY(IF(1-($B$1:$B$11=""),IF($C$1:$C$11=E4,MATCH($B$1:$B$11,$B$1:$B$11,0))),
    ROW($B$1:$B$11)-ROW($B$1)+1),1))
In E7 control+shift+enter, not just enter:
Rich (BB code):
=SUM(IF(FREQUENCY(IF(1-($B$1:$B$11=""),IF($D$1:$D$11=E6,MATCH($B$1:$B$11,$B$1:$B$11,0))),
    ROW($B$1:$B$11)-ROW($B$1)+1),1))
 
Upvote 0
Thank you so much!! I'll try this out and if any issues arrive, I'll bug you again. This message board is amazing! =)
 
Upvote 0
Hi Aladin,

I think you're super close at giving me the right code, but the counts need to include the duplicates once, otherwise I'm leaving them out of the tally. For example, if Calvin is listed twice, I need to count him once, including his correlating info, in my totals of individual/city/marital status and I believe the codes above discount the count of all duplicates entirely, instead of counting the duplicate solely once. I'm having a hard time communicating my needs so I completely understand if this is confusing. When I tried these codes in my actual report from lines 1:255, it leaves out the duplicates completely instead of counting them once. Let me know if what I'm asking for is possible, or if I'm misinterpreting the codes and they do in fact already do what I'm asking. THANKS AGAIN!
 
Upvote 0
Hi Aladin,

I think you're super close at giving me the right code, but the counts need to include the duplicates once, otherwise I'm leaving them out of the tally. For example, if Calvin is listed twice, I need to count him once, including his correlating info, in my totals of individual/city/marital status and I believe the codes above discount the count of all duplicates entirely, instead of counting the duplicate solely once. I'm having a hard time communicating my needs so I completely understand if this is confusing. When I tried these codes in my actual report from lines 1:255, it leaves out the duplicates completely instead of counting them once. Let me know if what I'm asking for is possible, or if I'm misinterpreting the codes and they do in fact already do what I'm asking. THANKS AGAIN!

jon
jonathan
jon
damon
damon
karl
damon

What is the count you expect for the above data?
 
Upvote 0

Forum statistics

Threads
1,215,480
Messages
6,125,048
Members
449,206
Latest member
Healthydogs

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