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

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
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,214,621
Messages
6,120,568
Members
448,972
Latest member
Shantanu2024

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