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.
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
Hi @simonhobman,
Can you please share your data struct and sample data? It will be help for analysis.
Regards,
Xiaoxin sheng
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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
106 | |
94 | |
77 | |
65 | |
53 |
User | Count |
---|---|
145 | |
105 | |
104 | |
90 | |
63 |