Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
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])))
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 98 | |
| 72 | |
| 50 | |
| 49 | |
| 44 |