Forum Discussion
Distinct Count if item Is This
I have a data set with Owner, Collaborator Type, and Folder. Owners can own multiple folders and each folder has a Collaborator Type of external or managed. I'd like to be able to get a distinct count of the number of owners 3 different ways.
- Owners who only have Managed folders
- Owners who only have External folders
- Owners who have both types
Right now I can sum the Distinct value of Owner+Managed or Owner+External but no idea how to count the sum of Owners that ONLY do one type or the other. Any help is greatly appreciated.
It looks like you've added a calculated column with that code.
The code is actually a measure definition, and won't make sense in a calculated column.
Here's a sample pbix file using your sample table
6 Replies
- OwenAugerSuper User
Hi legendsfan
So you want a distinct count of Owners that have exactly one Collaborator Type and that Collaborator Type = "Managed" (and the same for "External")?
My first thought would be to do something like this:
DistinctCount of Owners with Only Managed = CALCULATE ( DISTINCTCOUNT ( Data[Owner] ), FILTER ( VALUES ( Data[Owner] ), AND ( CALCULATE ( HASONEVALUE ( Data[Collaborator Type] ) ), FIRSTNONBLANK ( Data[Collaborator Type], 0 ) = "Managed" ) ) )or equivalently
DistinctCount of Owners with Only Managed = COUNTROWS ( FILTER ( VALUES ( Data[Owner] ), AND ( CALCULATE ( HASONEVALUE ( Data[Collaborator Type] ) ), FIRSTNONBLANK ( Data[Collaborator Type], 0 ) = "Managed" ) ) )Let me know if that is of any use.
Owen :)
- legendsfanFrequent Visitor
I don't believe this code is quite right based on the sample table I did a test on. In this case I'd expect the number to be 2 since only Daisy and Edward have folders that are exclusively Managed. Bob has Managed folders but he also has an External folder so he should not be counted. Thoughts?
- OwenAugerSuper User
It looks like you've added a calculated column with that code.
The code is actually a measure definition, and won't make sense in a calculated column.
Here's a sample pbix file using your sample table