Count unique values with multiple criteria

awalt

New Member
Joined
Aug 18, 2016
Messages
8
I am looking to count something specific, using multiple criteria, however I cannot use the COUNTIF function due to the way my workbooks are linked.

The goal is to count how many unique PARTY ID's fall within a given date range. I thought I had this working using the below formula, but it's not getting all the data. My goal is to count how many rooms I have per date range (unique party ID = room)

{=SUM(--(FREQUENCY(IF((criteria1)*(criteria2),values),values)>0))}

The party ID's should line up directly with the dates listed, however I believe the reason it is not capturing the data is because the PARTY IDs start 2 rows higher than my date ranges on sheet 2. I am not able to change how the sheets are laid out to make the PARTY ID start on the same line, but I can't figure out how to get this to calculate correctly. Below are some screen shots of what my data looks like.

Any help would be appreciated!

https://drive.google.com/file/d/1vnl2lH3mv_bZ4k1tTBkILbMdcHa2uwEa/view?usp=sharing
=SUM(--(FREQUENCY(IF((Sheet1!A:A="2019-12-12")*(Sheet1!B:B="2019-12-16"),Sheet2!A:A),Sheet2!A:A)>0))


https://drive.google.com/file/d/15f3YFngmLQY6qnYji3rtpr_wbZ1GzfDT/view?usp=sharing
https://drive.google.com/file/d/1idJh_pk9-DdU_Q2lwsW-TnF5Q-Oay4b-/view?usp=sharing
https://drive.google.com/file/d/1EUM2ZSI1u-CUOABy9RJQI-LPB1JyiCci/view?usp=sharing
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Not sure if this will work, but try

= SUM(--(FREQUENCY(IF(Sheet1!A:A = "2019-12-12",IF(Sheet1!B:B = "2019-12-16",Sheet2!A:A)),Sheet2!A:A>0)))
 
Upvote 0
Also I just noticed that when I did it on my computer I had the dates in other cells, i.e. in your photo maybe put the start date in row 4 and the end date in row 5, and then reference them in the formula

= SUM(--(FREQUENCY(IF(Sheet1!A:A = Sheet2!A4,IF(Sheet1!B:B = Sheet2!A5,Sheet2!A:A)),Sheet2!A:A>0)))

I tried typing in the dates in the formula as you have them and it did not work but did using the modification I mentioned above.
 
Upvote 0
Hi,

So sorry for the late reply! I tried the formula as you suggest above, which is counting the amount of time that date range appears in the list, but not limiting it based on the party ID on sheet 2. I am referencing my dates in sheet 4 as you suggested.

For example the date range 12/11/19 - 12/16/19 the count should be 4 since there are 4 party ID's with that date range, but the formula is returning 14, the # of times that date range appears in the dates sheet on sheet 1.

=SUM(--(FREQUENCY(IF(Sheet1!A:A=Sheet4!A2,IF(Sheet1!B:B=Sheet4!A7,Sheet2!A:A)),Sheet2!A:A>0)))
 
Upvote 0

Forum statistics

Threads
1,213,532
Messages
6,114,176
Members
448,554
Latest member
Gleisner2

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