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.
Heres the logic:
For each ContactID in ContactID column:
Count Distinct ( ProductIDs).
Next ContactID
My data looks like this (well this is a mockup...):
ContactID | ProductID |
ID1 | A |
ID1 | A |
ID1 | A |
ID1 | B |
ID1 | B |
ID2 | A |
ID2 | B |
ID2 | C |
ID1 | A |
ID1 | B |
So the answer is:
ContactID | CountDistinct | Values |
ID1 | 2 | (A, B) |
ID2 | 3 | (A, B, C) |
A Calculated Column would look like this
ContactID | ProductID | My Column |
ID1 | A | 2 |
ID1 | A | 2 |
ID1 | A | 2 |
ID1 | B | 2 |
ID1 | B | 2 |
ID2 | A | 3 |
ID2 | B | 3 |
ID2 | C | 3 |
ID1 | A | 2 |
ID1 | B | 2 |
Edit: need to use a calculated column, not a measure
FYI - Doing this in SSAS Tabular not Power BI, but I assume it's the same.
Thanks.
Solved! Go to Solution.
Then you can use this Calculated Column Formula:
My Column = CALCULATE(DISTINCTCOUNT(Table1[ProductID]),FILTER(Table1,Table1[ContactID]=EARLIER(Table1[ContactID])))
@Anonymous are you wanting your values to be concatenated ie. a,b,c?
Proud to be a Super User!
@vanessafvg No I've edited my post. I want the discinct count of productID's per each distinct contactID
You could either create a measure using DISTINCTCOUNT(ColumnName) or alternatively create a new table using SUMMARIZECOLUMNS (See more details here: https://msdn.microsoft.com/en-us/library/mt163696.aspx)
@kschaefers Now that I think about, this will actually need to be a calculated column, it cannot be a separate table though. The problem is that I need separate distinct counts for each contactID. I cannot just use distinctcount(ProductID) because that would ignore the ContactID column.
Then you can use this Calculated Column Formula:
My Column = CALCULATE(DISTINCTCOUNT(Table1[ProductID]),FILTER(Table1,Table1[ContactID]=EARLIER(Table1[ContactID])))
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 |
---|---|
108 | |
98 | |
78 | |
66 | |
53 |
User | Count |
---|---|
139 | |
100 | |
95 | |
85 | |
63 |