Remove duplicates from countifs statement based on another column's values

byrdbrain22

New Member
Joined
Jul 14, 2022
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hello,

I'm looking to accurately countifs a long series of data and remove the duplicates from that series based on another column's values. It seems like it shouldn't be that hard but haven't been able to find a solution. My data set has 10,000 rows, so I am not looking for a pivot table solution. Image attached with sample data set. Current formula in B3 is the following: =COUNTIFS($B$9:$B$15,$A3,$C$9:$C$15,B$2), it is returning 2 residential meters but there is a duplicate reading in the data set (row 9 and row 14). I want the answer to be only 1 in B3. How do I remove that duplicate based on the column A, which is the meter number?
I have tried combinations of sum, frequency, and ifs such as SUM(IF(COUNTIFS($B$12:$B$18,$B3,$C$12:$C$18,C$2),FREQUENCY(A12:A18,A12:A18)>0,1)).

Thank you for your help!
 

Attachments

  • Capture.PNG
    Capture.PNG
    23.2 KB · Views: 67

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Hi & welcome to MrExcel.
How about
Excel Formula:
=ROWS(UNIQUE(FILTER(A2:A15,($B$9:$B$15=$A3)*($C$9:$C$15=B$2))))
 
Upvote 0
Thank you! That worked! The only error I am getting is #CALC! when there are no values to count in the array for the filter function, so I just had to add the "if empty" condition. Final formula reads like this:=ROWS(UNIQUE(FILTER($A$9:$A$18,($B$9:$B$18=$A3)*($C$9:$C$18=B$2),0)))

THANK YOU SO MUCH:):)
 
Upvote 0
Thank you! That worked! The only error I am getting is #CALC! when there are no values to count in the array for the filter function, so I just had to add the "if empty" condition. Final formula reads like this:=ROWS(UNIQUE(FILTER($A$9:$A$18,($B$9:$B$18=$A3)*($C$9:$C$18=B$2),0)))

THANK YOU SO MUCH:):)
Sorry, one more question. So the "If empty" condition on the filter function returns a value if there is not a solution. However, if the option doesn't exist at all then it still counts "1". For example, if there are no landscape 2-inch meters, it still returns a "1" value in D5. Which is not correct, if it doesn't exist at all. What do you think?
 
Upvote 0
As you have discovered, you cannot use the If Empty condition. If col A are numeric values you can use Count instead of Rows, otherwise you need to use Iferror
Excel Formula:
=IFERROR(ROWS(UNIQUE(FILTER(A9:A15,($B$9:$B$15=$A3)*($C$9:$C$15=B$2)))),0)
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,151
Members
453,021
Latest member
Justyna P

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