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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
simonhobman
Frequent Visitor

list products in same category

I have two tables, Products and Categories (many products => one category).  My report is filtered on Product.

 

I want to create a calculated table to view the competing products (i.e. the other products in the same category).  Eventually I will rank them by sales, etc, but for now, I'm just piecing it together.

 

My first step was to create a DAX measure to give me the count of the competitors, this works great.

 

 

First Category Id = FIRSTNONBLANK(Category[Id], 1) 

 

 

Number of Competitors = 
VAR CategoryId = FIRSTNONBLANK(Category[Id], 1) RETURN
CALCULATE(
	COUNT(Products[Apir]),
	FILTER(ALL(Products), [First Category Id] = CategoryId)
)

 

The above result is that I get the number of products in the category, spot on. (Maybe it could be simpler???)

Next is where I'm stuck.  I want to list a table of all the competing products.  I've tried a few things but I haven't got it right. Based on what I did above, this is how I was looking at approaching the problem.

 

Competitor Products = 
VAR CategoryId = FIRSTNONBLANK(Category[Id], 1) RETURN
CALCULATETABLE(
	Products,
	FILTER(ALL(Products), [First Category Id] = CategoryId)
)

What I see in the table is all the products, they're not being filtered to the category.  I know i'm doing something wrong, just trying to figure this all out.

 

Many thanks

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @simonhobman,

 

Can you please share your data struct and sample data? It will be help for analysis.

 

Regards,

Xiaoxin sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
TomMartens
Super User
Super User

Hey,

 

not sure abaut your data model and its relationships

 

I would assume that there is the following relationship: products (many) <- category (one), meaning that each product just has one category assigned and that each category has many products assigned.

 

Can you please confirm my understanding or explain your model in more detail.

 

Regards



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi @TomMartens - you got it right. many products in one category.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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