count unique text values in a formula with multiple criteria

manchoon

New Member
Joined
Feb 17, 2016
Messages
8
Hi
I have data in columns like this below. A- sellers, B - shops, C- shop addresses

ABCDEFG
AnaAAaAnaAA
*

<tbody>
</tbody>
AnaBBd
TomAAc
HankCCe
AnaAAa
TomCCf
HankFFg
HankAAb
AnaAAa

<tbody>
</tbody>

<tbody>
</tbody>
.....

in cell H2 I need to count for example total number of shops ana has, or total number of addresses of AA shop...
I have data validation lists in cells E2, F2, G2 and I use them as criterias in formula. my formula should include something like a wildcard * which we use in sumifs because I might not indicate seller name and want to count total number of addresses of a specific shop, or I only choose seller name and I want number of addresses of every shop he/she has.

has anyone any idea how to do this? :/
thanks in advance
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
It looks like you are best off with COUNTIFS formula. Have you tried that and it did not work?
 
Upvote 0
Yes I tried but it doesn't exclude duplicate values

When you say H2, do you define the field as Ana and than countif using that parameter against the data you have? As far as duplicate's, did you try data tab -> remove duplicates function? That should remove duplicates from data if they are reoccurring more than they should
 
Upvote 0
In H2 I want to write a formula, which will count data by the criterias I will choose in cells E2, F2, G2. For example I will choose Ana (in E2) and AA (in F2), the result must be 1, I might choose only AA and result must be 3...
My data range is variable, so I need a formula which will change automatically when I refresh the data. I can't erase the duplicate values in data range completely, because I use this range in other formulas too and I need the duplicates there
 
Upvote 0
Is always one value present in E2:F2?

If so...

(a) When only E2 is available, what must be counted in H2?

(b) When only F2 is available, what must be counted in H2?

(c) when only G2 (apparently always *) is available, what must be counted in H2?
 
Upvote 0
Use an array formula if you are not comfortable using vba with dictionary count-
this formula should work in cell H2:
=SUM(IF($A$2:$A$11="Ana",1/(COUNTIFS($A$2:$A$11,"Ana",$B$2:$B$11,$B$2:$B$11)),0))
 
Upvote 0
Is always one value present in E2:F2?

If so...

(a) When only E2 is available, what must be counted in H2?

(b) When only F2 is available, what must be counted in H2?

(c) when only G2 (apparently always *) is available, what must be counted in H2?

if E2=* F2=* G2=*, formula should count all shop addresses (without duplicates). In this case it's 7

a) when only E2 is available for example Tom, formula should count all of Tom's shop addresses, in this case it's 2 (Tom AA c; Tom CC f), when I choose Hank, the answer is 3 (Hank CC e; Hank FF g; Hank AA b).
b) When only F2 is available for example AA, formula should count all addresses of shop AA, it doesn't matter whether it belongs to Ana, Tom or Hank (answer = 3).
c) when I choose a or other letters here it doesn't make sense, because there is only one shop with one address, but I still have a list here (which I use in other formulas on the sheet), so if I choose a, b,c or anything else the answer must be 1.
 
Upvote 0
Use an array formula if you are not comfortable using vba with dictionary count-
this formula should work in cell H2:
=SUM(IF($A$2:$A$11="Ana",1/(COUNTIFS($A$2:$A$11,"Ana",$B$2:$B$11,$B$2:$B$11)),0))

Thank you, it works perfectly with one criteria. But I don't understand how can I add another 2 criterias? Could you please help me out?
Does this formula recognize wildcard *? If I want to count all addresses of Hank for example, without specifying the shop?
 
Upvote 0
Machoon - this array formula is simple, to add multiple criteria you would need to append the first IF criteria section and also add the same one the 1/Countif Section:
=SUM(IF(($A$2:$A$11="Ana")*(Range2="Criteria 2")*(Range3="Criteria 3"),1/(COUNTIFS($A$2:$A$11,"Ana",Range2, Criteria2, Range3,Criteria3,$B$2:$B$11,$B$2:$B$11)),0))

Let me know if the explanation helps and if you were able to get your desired result
 
Upvote 0

Forum statistics

Threads
1,217,282
Messages
6,135,614
Members
449,952
Latest member
zhouxuanyu

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