Using countifs while excluding duplicates

Renaissance

Board Regular
Joined
Jun 20, 2013
Messages
58
Hey Everyone! I just wanted to start off by saying I've been reading the forums for quite some time now and have been able to find a solution through everyone's examples. Now, it looks like I am at an impasse, though.

I currently have a large quantity of raw data that has many different uses columns A:AB with row 1 as headers, while the rows are in the 50,000+. My situation is that I am pulling the total cost of data through a period & call number, while dividing it by the amount of entries from that same data, minus duplicates.

I've been able to use examples like: =SUM(1/COUNTIF(NAMES,NAMES)) for other sets of data. But this one is a bit more complicated.

So far I have been using: =IFERROR(SUMIFS('Raw Data'!$W:$W,'Raw Data'!$R:$R,$C$3,'Raw Data'!$S:$S,F$4,'Raw Data'!$B:$B,$D5)/COUNTIFS('Raw Data'!$R:$R,$C$3,'Raw Data'!$S:$S,F$4,'Raw Data'!$B:$B,$D5),"-")

What I need to do is replace the /COUNTIFS part (or modify it) to exclude duplicates. In this case they are Purchase Order numbers. I don't need to divide a single cost by 4, if they are all a part of that same cost, if that makes sense.

Thanks for any and all time spent in my dilemma. And if I need to insert an excerpt of my raw data, I can.
 
CSE...

=SUM(IF(FREQUENCY(IF('Raw Data'!$D$2:$D$50652<>"",
IF('Raw Data'!$B$2:$B$50652=$D5,
IF('Raw Data'!$R$2:$R$50652=$C$3,
IF('Raw Data'!$S$2:$S$50652=R$4,
MATCH('Raw Data'!$D$2:$D$50652,'Raw Data'!$D$2:$D$50652,0))))),
ROW('Raw Data'!$D$2:$D$50652)-ROW('Raw Data'!$D$2)+1),1))

You might get a noticeable performance degradation.

It yields 0. Drat! And the performance degradation is minimal. Hmm...Would it change any if I used named ranges instead? Also, does the order change anything? Gosh, I can't believe how difficult this is. I'm sure I'm not the only person trying to utilize multiple criteria, excluding duplicates. Hmmmmm.

Thanks again for all of your help. I know we're very close.
 
Upvote 0

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
It yields 0. Drat! And the performance degradation is minimal. Hmm...Would it change any if I used named ranges instead? Also, does the order change anything? Gosh, I can't believe how difficult this is. I'm sure I'm not the only person trying to utilize multiple criteria, excluding duplicates. Hmmmmm.

Thanks again for all of your help. I know we're very close.

Is the following any different?

=SUM(IF(FREQUENCY(IF('Raw Data'!$D$2:$D$50652<>"",
IF('Raw Data'!$B$2:$B$50652=$D5,
IF(TRIM('Raw Data'!$R$2:$R$50652)=$C$3,
IF(TRIM('Raw Data'!$S$2:$S$50652)=R$4,
MATCH('Raw Data'!$D$2:$D$50652,'Raw Data'!$D$2:$D$50652,0))))),
ROW('Raw Data'!$D$2:$D$50652)-ROW('Raw Data'!$D$2)+1),1))
 
Upvote 0
Upvote 0
That gave me an error, so I added what I thought needed to be added, and now I am getting #N/A with:

=SUM(IF(FREQUENCY(IF('Raw Data'!$D$2:$D$50652<>"",
IF('Raw Data'!$B$2:$B$150652=$C$3,
IF('Raw Data'!$R$2:$R$50652=$D5,
IF('Raw Data'!$S$2:$S$150652=E$4,
MATCH('Raw Data'!$D$2:$D$50652,'Raw Data'!$D$2:$D$50652,0))))),
ROW('Raw Data'!$D$2:$D$50652)-ROW('Raw Data'!$D$2)+1),1))
 
Upvote 0
That gave me an error, so I added what I thought needed to be added, and now I am getting #N/A with:

=SUM(IF(FREQUENCY(IF('Raw Data'!$D$2:$D$50652<>"",
IF('Raw Data'!$B$2:$B$150652=$C$3,
IF('Raw Data'!$R$2:$R$50652=$D5,
IF('Raw Data'!$S$2:$S$150652=E$4,
MATCH('Raw Data'!$D$2:$D$50652,'Raw Data'!$D$2:$D$50652,0))))),
ROW('Raw Data'!$D$2:$D$50652)-ROW('Raw Data'!$D$2)+1),1))

I have first reduced the range sizes 2..50652 to 1..12 for testing and tried to revert back to the original size using copy paste. So doing I introduced an unequally sized range in a subexpression, etc., a state of affairs that causes #N/A... Corrected for that, we have:

Control+shift+enter:
Rich (BB code):
=SUM(IF(FREQUENCY(IF('Raw Data'!$D$2:$D$50652<>"",
   IF('Raw Data'!$B$2:$B$50652=$C$3,
  IF('Raw Data'!$R$2:$R$50652=$D5,
   IF('Raw Data'!$S$2:$S$50652E$4,
     MATCH('Raw Data'!$D$2:$D$50652,'Raw Data'!$D$2:$D$50652,0))))),
       ROW('Raw Data'!$D$2:$D$50652-ROW('Raw Data'!$D$2)+1),1))
 
Upvote 0
I have first reduced the range sizes 2..50652 to 1..12 for testing and tried to revert back to the original size using copy paste. So doing I introduced an unequally sized range in a subexpression, etc., a state of affairs that causes #N/A... Corrected for that, we have:

Control+shift+enter:
Rich (BB code):
=SUM(IF(FREQUENCY(IF('Raw Data'!$D$2:$D$50652<>"",
   IF('Raw Data'!$B$2:$B$50652=$C$3,
   IF('Raw Data'!$R$2:$R$50652=$D5,
   IF('Raw Data'!$S$2:$S$50652E$4,
     MATCH('Raw Data'!$D$2:$D$50652,'Raw Data'!$D$2:$D$50652,0))))),
       ROW('Raw Data'!$D$2:$D$50652-ROW('Raw Data'!$D$2)+1),1))

Another edit...

Control+shift+enter:
Rich (BB code):
=SUM(IF(FREQUENCY(IF('Raw Data'!$D$2:$D$50652<>"",
   IF('Raw Data'!$B$2:$B$50652=$C$3,
   IF('Raw Data'!$R$2:$R$50652=$D5,
   IF('Raw Data'!$S$2:$S$50652=E$4,
     MATCH('Raw Data'!$D$2:$D$50652,'Raw Data'!$D$2:$D$50652,0))))),
       ROW('Raw Data'!$D$2:$D$50652-ROW('Raw Data'!$D$2)+1),1))
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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