Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
jameshoneywill
Frequent Visitor

Average number of product bought from a hierarchy level

Hi 

I have a sales table and a products table, joined on productID. 

There are productIDs for individual products but these then sit under several groupings, e.g. products apples, oranges, and pineapples are under Fruit, which in tern is under Food, also under food is Vegtables, which has individual products(and IDs) for carrorts and potatoes etc. etc. 

I want to do a unique count of how many food groups a customer buys.
i.e. 
if they buy apples oranges and carrots the answer is 2 NOT 3

But I can't work out how to do this without merging in the food group into the sales table via power query, which I don't want to do....

Surely there is a DAX measure which can count how many unique food groups a customer buys based on what ID's are in their sales table for that month.... I really can't get my head around how to do it!

TIA

1 ACCEPTED SOLUTION
Deku
Super User
Super User

Countrows( Summarize( sales, product[category] ) )


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

HI,

Share some data to work with and show the expected result.  Share data in a format that can be pasted in an MS Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
ArwaAldoud
Super User
Super User

Hi @jameshoneywill try this measure below 

 

UniqueFoodGroupsBought =
CALCULATE(
DISTINCTCOUNT(Products[FoodGroup]),
SUMMARIZE(
Sales,
Sales[CustomerID],
Products[FoodGroup]
)
)

 

If this response was helpful, please accept it as a solution and give kudos to support other community members

Deku
Super User
Super User

Countrows( Summarize( sales, product[category] ) )


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors