Average of a distinct count based on criteria

XLearn

New Member
Joined
Aug 24, 2017
Messages
2
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
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
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")
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,215,357
Messages
6,124,483
Members
449,165
Latest member
ChipDude83

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