Count values based on criteria with no duplicates

leterrier

New Member
Joined
Jan 5, 2013
Messages
44
Apologies if this has been answered elsewhere but I cannot find it.

I need an excel formula to count text values (that may include blanks) in one column based on criteria from an adjacent column. I only want to count duplicates once and exclude blanks. Eg if cells in column contain "x", count all corresponding unique values in column B excluding blanks. It's sounds simple but it has foxed me so for. I'm grateful for your learned help! PS bonus if it can be achieved without using an array formula but I can live with it if it's the best solution. Thank you.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
do you want to find no. of cells in column B containing "X" as one word or
do you want to find no. of cells in columb containing various words containing character "x"

if former you use count if

suppose col B contains

x
x
c
v
x
c
d
f
g

B2 blank

then use formula
=COUNTIF(B1:B10,"x")


<colgroup><col width="64" style="width:48pt"> </colgroup><tbody>
</tbody>
 
Upvote 0
Thank you Venkat1926, I didn't make myself too clear in this thread, I will have a think on how to rephrase and try again. Thank you once again for your time!
 
Upvote 0
Apologies if this has been answered elsewhere but I cannot find it.

I need an excel formula to count text values (that may include blanks) in one column based on criteria from an adjacent column. I only want to count duplicates once and exclude blanks. Eg if cells in column contain "x", count all corresponding unique values in column B excluding blanks. It's sounds simple but it has foxed me so for. I'm grateful for your learned help! PS bonus if it can be achieved without using an array formula but I can live with it if it's the best solution. Thank you.

Control+shift+enter, not just enter:
Rich (BB code):
=SUM(IF(FREQUENCY(IF($B$2:$B$100<>"",IF($C$2:$C$100="x",
  MATCH("~"&$B$2:$B$100,$B$2:$B$100&"",0))),
  ROW($B$2:$B$100)-ROW($B$2)+1),1))
 
Upvote 0
Aladin, Thank you so much for taking the time to respond, unfortunately, this formula is returning a "you have entered too few arguments for this function" error message:(
 
Upvote 0
Garment Type (A)
Colour (B)
Comment
Hats
red
Cotsgreen
Scarves
blue
Hats
green
Coats
red
Scarvesblue
Hats
red
Coatsgreen
Hats
blank
Scarves
red

<tbody>
</tbody>




















I wish to know how many different coloured hats have been sold, the answer is 2 (red and green).

The formula I need is: if the criteria in column A is "hats", how many unique values are in column B - excluding blanks? The answer is 2 (red and green)

Thanks
 
Upvote 0
Control+shift+enter, not just enter:
Rich (BB code):
=SUM(IF(FREQUENCY(IF(1-($B$2:$B$11=""),IF($A$2:$A$11="Hats",
  MATCH("~"&$B$2:$B$11,$B$2:$B$11&"",0))),ROW($B$2:$B$11)-ROW($B$2)+1),1))
 
Upvote 0
Aladin, Thank you again for your help, its working perfectly, I was not getting the array right. Thanks for your patience!!!!


Control+shift+enter, not just enter:
Rich (BB code):
=SUM(IF(FREQUENCY(IF($B$2:$B$100<>"",IF($C$2:$C$100="x",
  MATCH("~"&$B$2:$B$100,$B$2:$B$100&"",0))),
  ROW($B$2:$B$100)-ROW($B$2)+1),1))
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,930
Members
449,094
Latest member
teemeren

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