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.
Hello friends,
I'm still a beginner and I was performing an assessment which asked me to use "COUNTDISTINCT" to get the number of stores each product was sold in.
This is the full table in the data view:
And here is the final solution:
Can you help me understand how to get the number of stores sold in to look as same as we see in the solution ?
Thanks in advance!
Solved! Go to Solution.
Hi @Trooz ,
Please use below measures:
// You should have a dimension
// Store in your model and a Sales
// fact table. Store joins on StoreID
// to the fact table.
// This measure gives you the number
// of different stores that ANY of
// the products currently in scope
// has been sold. If only one product
// is in scope you'll get the number
// of stores that the product has
// been sold in.
[# Distinct Stores] =
DISTINCTCOUNT( Sales[StoreId] )
// If you now put your products
// on rows and drop this measure
// you'll see the number of different stores
// the product has been sold in. This
// also works with all slicers you
// could think of.
Best
D
// You should have a dimension
// Store in your model and a Sales
// fact table. Store joins on StoreID
// to the fact table.
// This measure gives you the number
// of different stores that ANY of
// the products currently in scope
// has been sold. If only one product
// is in scope you'll get the number
// of stores that the product has
// been sold in.
[# Distinct Stores] =
DISTINCTCOUNT( Sales[StoreId] )
// If you now put your products
// on rows and drop this measure
// you'll see the number of different stores
// the product has been sold in. This
// also works with all slicers you
// could think of.
Best
D
- I've created "Centre-Info" table to be as dim-table (In this table I deleted the duplicated values to have only the centres as a unique value" then linked this table to the fact table "Sales-Info"
So what should be the next step then? 🙂
Hi @Trooz ,
Please use below measures:
Thank you, It worked 👍
Could you please explain why did chose this specific formulas "Countdistinct" and "Allexcept" ... I mean what is the moral of using those formulas?
Hi @Trooz ,
Think of ALL Except as as 'Grouping" in Business Terms.
For Quantity : I want to SUM the Quantity by the Product Name and the Centre Id.
For Store Sold : I want to Count the stores by Product Name and Centre Id And I do not want to count a store which comes in this group twice, thus I should use Distinct.
I would also suggest that you follow @Anonymous solution because you should get the data models correct which will help scale your solution and avoid any performance issues.
Fact and Dimension tables are key to get your solution working correctly.
Thanks and Regards,
Harsh Nathani
Thanks a lot for your help. I've created a new dim table and in case of problems I'll get back to you 🙂
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 |
---|---|
47 | |
26 | |
19 | |
14 | |
10 |
User | Count |
---|---|
57 | |
49 | |
44 | |
18 | |
18 |