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,
Hope to get some help here. I have a situation where I only want to count the UniqueID that has duplicates. Right now it is giving me 6 counts where as I expect to get only 4 accounts when selecting only Apple and Banana.
DataTable
UniqueID | Attribute | Value |
31464 | Grapes | FALSE |
31464 | Apple | TRUE |
31766 | Apple | TRUE |
31464 | Coconut | TRUE |
31471 | Apple | FALSE |
31471 | Grapes | FALSE |
31471 | Banana | FALSE |
31471 | Coconut | FALSE |
36033 | Apple | TRUE |
31766 | Coconut | FALSE |
36390 | Apple | TRUE |
31766 | Grapes | FALSE |
31464 | Banana | TRUE |
32420 | Apple | FALSE |
32420 | Grapes | FALSE |
32420 | Coconut | FALSE |
32624 | Grapes | FALSE |
32624 | Apple | FALSE |
32624 | Banana | FALSE |
32624 | Coconut | FALSE |
35764 | Apple | FALSE |
35764 | Grapes | TRUE |
31766 | Banana | TRUE |
35764 | Coconut | TRUE |
32420 | Banana | TRUE |
36033 | Grapes | TRUE |
35764 | Banana | TRUE |
36033 | Coconut | FALSE |
36033 | Banana | TRUE |
36390 | Banana | TRUE |
36390 | Grapes | FALSE |
36390 | Coconut | FALSE |
Expected result when choosing Apple and Banana only, with True.
UniqueID | Attribute | Value |
31464 | Apple | TRUE |
31464 | Banana | TRUE |
31766 | Apple | TRUE |
31766 | Banana | TRUE |
36033 | Apple | TRUE |
36033 | Banana | TRUE |
36390 | Apple | TRUE |
36390 | Banana | TRUE |
32420 | Banana | TRUE |
35764 | Banana | TRUE |
Hope to get some help, thanks.
Solved! Go to Solution.
Try this measure:
Count UniqueID Duplicates =
SUMX (
--iterate the distinct UniqueIDs in the filter context
VALUES ( DuplicateCount[UniqueID] ),
--current UniqueID
VAR vUniqueID = DuplicateCount[UniqueID]
--return the rows for the current UniqueID in the filter context
VAR vUniqueIDRows = FILTER ( ALLSELECTED ( DuplicateCount ), DuplicateCount[UniqueID] = vUniqueID )
--if the current UniqueID has more than one row, assign a count of 1
VAR vUniqueIDCount = IF ( COUNTROWS ( vUniqueIDRows ) > 1, 1 )
RETURN
vUniqueIDCount
)
Proud to be a Super User!
Here is another similar way to do it.
IDs with Duplicates =
COUNTROWS (
FILTER (
DISTINCT ( UniqueDuplicates[UniqueID] ),
CALCULATE (
COUNTROWS ( UniqueDuplicates ) = 2
)
)
)
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Thanks, this works too!
Try this measure:
Count UniqueID Duplicates =
SUMX (
--iterate the distinct UniqueIDs in the filter context
VALUES ( DuplicateCount[UniqueID] ),
--current UniqueID
VAR vUniqueID = DuplicateCount[UniqueID]
--return the rows for the current UniqueID in the filter context
VAR vUniqueIDRows = FILTER ( ALLSELECTED ( DuplicateCount ), DuplicateCount[UniqueID] = vUniqueID )
--if the current UniqueID has more than one row, assign a count of 1
VAR vUniqueIDCount = IF ( COUNTROWS ( vUniqueIDRows ) > 1, 1 )
RETURN
vUniqueIDCount
)
Proud to be a Super User!
Thank you! This is the solution I needed because it works with Filter context and I can add many other slicers to it. You're the best!
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 |
---|---|
112 | |
100 | |
80 | |
64 | |
57 |
User | Count |
---|---|
146 | |
110 | |
93 | |
84 | |
67 |