Forum Discussion
Find Distinct Data - Based On Two Columns
I have a database where I would like to identify unique codes that a particular person has not identified or coded. Below is an example of my problem.
Problem: I would like to exclude all of the codes "Name A" has identified/coded as well as the other "Names" for those identify codes, please see the data example below.
Excluding just "Name A" codes is easy however i also want to remove the "Names" associated with Code 3 & Code 18 since they are also related to code "Name A" has identifed/captured.
| Name | Code |
| Name G | 1 |
| Name C | 1 |
| Name G | 2 |
| Name F | 2 |
| Name B | 2 |
| Name G | 3 |
| Name F | 3 |
| Name A | 3 |
| Name A | 4 |
| Name A | 5 |
| Name A | 6 |
| Name A | 7 |
| Name B | 8 |
| Name B | 9 |
| Name F | 10 |
| Name B | 10 |
| Name F | 11 |
| Name G | 12 |
| Name A | 13 |
| Name D | 14 |
| Name G | 15 |
| Name D | 15 |
| Name C | 16 |
| Name A | 17 |
| Name G | 18 |
| Name A | 18 |
| Name B | 18 |
| Name H | 19 |
| Name G | 19 |
Hi rhcentennialh ,
We use the following measure and get the expected result:
Not identified by Outside = IF ( SELECTEDVALUE ( 'Table'[Code] ) IN SELECTCOLUMNS ( FILTER ( ALLSELECTED ( 'Table' ), [Internal vs Outside] = "Internal" ), "c", [Code] ), BLANK (), "YES" )BTW, pbix as attached.
Best regards,
Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.Hi rhcentennialh ,
Can it filter the data you want if we put the following measure into the Visual Filter then set the condition as greater than zero? Please try it without the measure in the value filed of table visual.
Not identified by Outside 2 = IF ( SELECTEDVALUE ( 'Table'[Code] ) IN SELECTCOLUMNS ( FILTER ( ALLSELECTED ( 'Table' ), [Internal vs Outside] = "Internal" ), "c", [Code] ), 0 , 1 )Best regards,
Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
20 Replies
- v-lid-msftCommunity Support
Hi rhcentennialh ,
We can create a calculated table using following DAX:
Table 2 = SELECTCOLUMNS ( FILTER ( ADDCOLUMNS ( DISTINCT ( SELECTCOLUMNS ( FILTER ( 'Table', 'Table'[Name] = "Name A" ), "Code-2", [Code] ) ), "CountOther", COUNTROWS ( FILTER ( 'Table', AND ( 'Table'[Name] <> "Name A", 'Table'[Code] = [Code-2] ) ) ) ), ISBLANK ( [CountOther] ) ), "Code", [Code-2] )Or we can add a calculated column to the table.
isDistinct = VAR c = [Code] VAR n = [Name] RETURN IF ( n = "Name A", IF ( COUNTROWS ( FILTER ( ALL ( 'Table' ), AND ( 'Table'[Code] = c, 'Table'[Name] <> n ) ) ) + 0 = 0, "YES", "No" ), "NO" )If you want to get the dymanic result based on the slicer on user name, we can try the following measure:
isDistinct-Measure = IF ( COUNTROWS ( FILTER ( ALL ( 'Table' ), AND ( 'Table'[Code] IN FILTERS ( 'Table'[Code] ), NOT 'Table'[Name] IN FILTERS ( 'Table'[Name] ) ) ) ) + 0 = 0, "YES", BLANK () )BTW, pbix as attached.
Best regards,
Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.- rhcentennialhHelper II
I don't believe this addresses my problem.
1.) I am needing to remove all the codes that "Name A" has identified.
2.) I am also needing to remove the Names associated with the codes "Name A" has identified. But only for those codes that have matched, any other Codes that were not also identified by "Name A" I want to keep.
For Example:
A.) "Name B" identified the following codes (2,8,9,10,18)
B.) "Name A" also identified code (18)
Result = I would want the table to show the Name & Codes (2,8,9,10). It will exclude (18) since it was captured by both "Name A" & "Name B"
- v-lid-msftCommunity Support
Hi rhcentennialh ,
We can use the following measure to meet your requirement:
Not identified by A = IF ( SELECTEDVALUE ( 'Table'[Code] ) IN SELECTCOLUMNS ( FILTER ( ALL ( 'Table' ), [Name] = "Name A" ), "c", [Code] ), BLANK (), "YES" )Use this measure in table visual and add Slicer in Name Field.
BTW, pbix as attached.
Best regards,
Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.