# Average of a distinct count based on criteria

#### XLearn

##### New Member
Hi,
I'm new to power pivots and dax formulas.

Does anyone know how I can work out the average value of distinct count based on a criteria?
Let's assume I have the tables below

Customer Table
Customer - Region
a - AA
b - AA
c - BB
d - CC

Product Table
Product - Type
1 - X
2 - X
3 - Y
4 - Z

Sales Table

Time - Product - Customer
Day 1 - 1 - a
Day 1 - 2 - a
Day 1 - 3 - a
Day 1 - 1 - b
Day 1 - 2 - c

On any given day (which I can use a power pivot filter for) how do I create a DAX formula that tells me region AA saw 3 unique product types purchased?

Hoping this is easy enough for the experts.
Thanks

#### Matt Allington

##### MrExcel MVP
You need this measure. =distinctcount(sales[product])

you cna then filter on day and region, and the above will give you the result. If you want to know region a specifically, then you need this.

Calculate(distinctcount(sales[product]),customer[region]="AA")

#### XLearn

##### New Member
Thanks Matt,

This works perfectly when I need to see results for just one region. But how do I tweak this so it shows me the average number of product types purchased by all regions.

So using my above example region AA saw 2 product types purchased (X & Y) whereas regions BB and CC saw 1 product type purchased.
So using my formula if I applied no filter to my power pivot I would like it to display the result 1.33 which is the average of 2,1 & 1 : (2+1+1)/3

Hopefully this makes sense.
XLearn

1,081,415
Messages
5,358,533
Members
400,502
Latest member
price83

### This Week's Hot Topics

• VBA (Userform)
Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
• List box that changes fill color
Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
• Remove duplicates and retain one. Cross-linked cases
Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
• VBA Copy and Paste With Duplicates
Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
• Macro
is it possible for a macro to run if the active cell value is different to the value above it
• IF DATE and TIME
I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...