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.
Hi all,
I have a table like this:
Country, Advertiser, Brand, Spend C1, A1, B1, 10 C1, A1, B2, 5 C1, A2, B3, 0 C1, A2, B4, 20 C2, A1, B1, 8 C2, A1, B5, 7 C2, A2, B6, 4 C2, A2, B3, 3 C2, A2, B7, 2 C2, A3, B8, 9
I'd like to find the DISTINCT COUNT of Brands by Country as below:
C1 => 4 C2 => 6
How do I create a Measure in Power BI Desktop to achieve this?
Thank you for your answers/suggestions!
Solved! Go to Solution.
hello @plartoo,
Possibly I'm over simplifying your problem however I've accomplished your desired output with 2 different measures:
Measure = CALCULATE(COUNTROWS(Table3),DISTINCT(Table3[Country])) Measure 2 = COUNTROWS(Table3)
Also I used Count of Brand in the Values area as well.
Measure 3 = CALCULATE(DISTINCTCOUNT(Table3[Brand]), GROUPBY(Table3,Table3[Country]))
Was taken from https://stackoverflow.com/questions/50414271/creating-a-measure-that-returns-distinct-count-by-count... which looks exactly like your question.
DISTINCTCOUNT in Measure 3 is returning 8 because 'B1' & 'B3' is only counted once over the entire data set.
Proud to be a Super User!
Here is a single measure solution. Put this in a table along with Country.
Measure = VAR __tmpTable = SUMMARIZE(brands,brands[Country],"__Brands",DISTINCTCOUNT(brands[ Brand])) RETURN MAXX(__tmpTable,[__Brands])
hello @plartoo,
Possibly I'm over simplifying your problem however I've accomplished your desired output with 2 different measures:
Measure = CALCULATE(COUNTROWS(Table3),DISTINCT(Table3[Country])) Measure 2 = COUNTROWS(Table3)
Also I used Count of Brand in the Values area as well.
Measure 3 = CALCULATE(DISTINCTCOUNT(Table3[Brand]), GROUPBY(Table3,Table3[Country]))
Was taken from https://stackoverflow.com/questions/50414271/creating-a-measure-that-returns-distinct-count-by-count... which looks exactly like your question.
DISTINCTCOUNT in Measure 3 is returning 8 because 'B1' & 'B3' is only counted once over the entire data set.
Proud to be a Super User!
Thank you, Dozer. This solution works! I'll ask another follow-up question about how to make this distinct count value appear in a Tree-map soon. 🙂
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 |
---|---|
110 | |
94 | |
82 | |
66 | |
58 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |