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
Anonymous
Not applicable

Delete rows if one column is a duplicate and a different row has a specific value

So I have multiple people assigned to different 'Tasks'. I want only 1 person assigned to each task. I know the names of the people whose tasks I want to keep. So basically:

TaskAgent
1Joe
1Sally
2Patricia
3Joe
3Debra
4Joe


In this example, I want to delete the duplicate tasks based on if Joe is the agent. If the task isn't a duplicate and Joe is assigned, I still want to keep it.

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @Anonymous 

 

Try to add a new table with this code:

 

New Table =
FILTER (
    'Table',
    'Table'[Agent] = "Joe"
        || CALCULATE (
            DISTINCTCOUNT ( 'Table'[Agent] ),
            ALLEXCEPT ( 'Table', 'Table'[Task] )
        ) = 1
)

 

 

Output:

 

VahidDM_1-1632446810186.png

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos✌️!!

 

View solution in original post

3 REPLIES 3
v-jayw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Not sure if I understand your correctly but the formula provided by @VahidDM  is basically correct.

You might need to modify “= Joe” to “<> Joe".

 

Table 2 = 
FILTER (
    'Table',
    'Table'[Agent] <> "Joe"
        || CALCULATE (
            DISTINCTCOUNT ( 'Table'[Agent] ),
            ALLEXCEPT ( 'Table', 'Table'[Task] )
        ) = 1
)

 

Capture.PNG

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
VahidDM
Super User
Super User

Hi @Anonymous 

 

Try to add a new table with this code:

 

New Table =
FILTER (
    'Table',
    'Table'[Agent] = "Joe"
        || CALCULATE (
            DISTINCTCOUNT ( 'Table'[Agent] ),
            ALLEXCEPT ( 'Table', 'Table'[Task] )
        ) = 1
)

 

 

Output:

 

VahidDM_1-1632446810186.png

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos✌️!!

 

ryan_mayu
Super User
Super User

@Anonymous 

you can use DAX to create a new table

Table 2 = 
VAR tbl1=ADDCOLUMNS('Table',"check",if('Table'[Task]=maxx(FILTER('Table','Table'[Task]=EARLIER('Table'[Task])&&'Table'[Agent]="Joe"),'Table'[Task]),"Yes"))
VAR tbl2=FILTER(tbl1,[check]="")
VAR tbl3=FILTER(tbl1,[check]="Yes"&&'Table'[Agent]<>"Joe")
return SELECTCOLUMNS(union(tbl2,tbl3),"Task",'Table'[Task],"Agent",'Table'[Agent])

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.