Counting unique values by date condition and another criteria

mhessnm

Board Regular
Joined
Apr 12, 2019
Messages
57
Office Version
  1. 365
Platform
  1. Windows
Hello, I have looked all over but I don't seem to find an answer to my particular question.

I am trying to count unique client id values by month and by another criteria, in this case gender.

Client IDDateGender
11217/1/21Male
11477/5/121Female
11217/16/21Male
78658/2/21Female
56748/4/21Male
78658/8/21Female
98768/17/21Female

In the table above, I should be able to find that there is 1 unique male and one unique female in July, and 2 unique females and 1 unique male in August, and that as I copy the formula down alongside a unique list of months, under columns for Male and Female, I would get those unique numbers.

I have been trying all kinds of different formulas and nothing is working. I seem to have trouble when I try to use the MONTH function in an array, regardless of whether I CSE or not. I have tried various ways of using UNIQUE and COUNT or COUNTA. I saw some formulas using FREQUENCY but I have not been able to make those work. I have also tried SUMPRODUCT and SUM(IF(COUNTIF...and also using COUNTIFS.

I have even tried a pivot table but while I can get a unique list of months, it still gives me a count of all the records within the month for gender.

I'm frustrated because I'm missing something and I don't know what it is. I also find working with dates as a criteria, particularly with counting, to be very difficult to work with in formulas.

I'd appreciate any suggestions.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Hello, sorry to have bothered you all. I finally found the answer. It was using UNIQUE with FILTER, and multiplying two criteria within FILTER, then counting the uniques:

=COUNT(UNIQUE(FILTER(range to filter, (filter criteria 1)*(filter criteria 2))))

If you read this, thank you in advance.
 
Upvote 0
It was using UNIQUE with FILTER,
Those two functions do not exists in xl 2016, so maybe you need to update your profile if you have them.

Also if there is a possibility that there will not be any rows that match the criteria, you would be better off using
Excel Formula:
=ROWS(UNIQUE(FILTER(range to filter, (filter criteria 1)*(filter criteria 2))))
count will return 1 even if there are no matches.
 
Upvote 0
Solution
Those two functions do not exists in xl 2016, so maybe you need to update your profile if you have them.

Also if there is a possibility that there will not be any rows that match the criteria, you would be better off using
Excel Formula:
=ROWS(UNIQUE(FILTER(range to filter, (filter criteria 1)*(filter criteria 2))))
count will return 1 even if there are no matches.
Done, Fluff. I have 365. And thank you very much for providing an updated code. I appreciate your attention and suggestions.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
You're welcome & thanks for the feedback.
Hi,
I am working on a similar formula and think the answer is here:
What did you put in this formula to get the date criteria to specify a date range to count the data from?
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,186
Members
452,615
Latest member
bogeys2birdies

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