Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
sjrrkb123
Helper III
Helper III

Finding Duplicates in a Table

So I have worked with finding duplicates a lot in the past but I am struggling in the current situation. 

What I am trying to do is to find any professional keys that exist in both the "Owner" & "Sponsor Roles." If the professional key exists in both, then the column "Dual Role Check" will equal 1, else 0. This needs to be scoped to a given project key.

Here is what my data looks like:

Project Key Professional Key Role Name
222622 123 Sponsor
222622 105 Director
222622 123 Owner
222622 106 Partner
222622 314 Manager

222623

 455 Sponsor
222623 416 Director
222623 314 Owner
222623 444 Partner
222623 024 Manager


What I want is the following:

Project Key Professional Key Role Name Dual Role Check
222622 123 Sponsor 1
222622 105 Director 0
222622 123 Owner 1
222622 106 Partner 0
222622 314 Manager 0

222623

 455 Sponsor 0
222623 416 Director 0
222623 314 Owner 0
222623 444 Partner 0
222623 024 Manager 0


Here is the function I have tried:

 

 

 

 

 

Dual Role Check = 
var es_key = IF([Role Name] = "Sponsor", [Professional Key], Blank())
var ow_key = IF([Role Name] = "Owner", [Professional Key], Blank())
RETURN

CALCULATE(COUNT('Data'[Professional Key]), 
    FILTER('Data', 'Data'[Project Key] = EARLIER('Data'[Project Key])),
    ow_key = es_key)


Any help would be appreciated!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@sjrrkb123 , Create a new column like

 

new column =
var _1 = countx(filter(Table, [Project Key] = earlier([Project Key]) && [Professional Key] && earlier([Professional Key])),[Project Key])
return
if(_1 >1, 1,0)

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@sjrrkb123 , Create a new column like

 

new column =
var _1 = countx(filter(Table, [Project Key] = earlier([Project Key]) && [Professional Key] && earlier([Professional Key])),[Project Key])
return
if(_1 >1, 1,0)

@amitchandak  it worked Great! I had to tweak it with the following but I appreciate the help greatly.

new column =
var _1 = countx(filter(Table, [Project Key] = earlier([Project Key]) && [Professional Key] && earlier([Professional Key]) && RoleName IN {"Sponsor", "Owner"}),[Project Key])
return
if(_1 >1, 1,0)

as I only care about duplicates in those two roles. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.