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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
ljx0648
Helper III
Helper III

How to remove duplicate based on one condition

Hi guys,

 

I have a rather simple data table structure like below:

 

IDAssigned toPhone Available
1AYES
1AYES
2BNO 
2BYES
3CNO
3CNO

 

I need to remove duplicate but i need to keep record with YES if the record also has a NO (i.g. ID2 with B in the case here)

 

Desired output:

IDAssigned toPhone Available
1AYES
2BYES

3

CNO

 

May I know how to achieve the result above in Power Query? Or if there is any way to remove duplicate after importing from Power Query?

 

I have tried a method by creating an additioanl column named "sort" when phone column = yes then 1 else 2, after that I sort it ascending and remove duplicate, but the result return for ID 2 is still NO. The reason I believe is the Power Query still sorting from the source using Phone Available then the column I created. 

 

I have also searched on the forum and google but none of the method works.

 

Any tips are much appreciated!

 

Thank you guys

1 ACCEPTED SOLUTION
audreygerred
Super User
Super User

Hi! I have the following data entered:

audreygerred_0-1706899842636.png

 

In Power Query, I sorted Phone descensding so that all the Yes are above all the No. I then added an index column, and then removed duplicates on ID. VIOLA! It keeps the first instance in the list which will be Yes because of the sorting and indexing.

audreygerred_1-1706899934432.pngaudreygerred_2-1706899958726.png

 

 





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

Proud to be a Super User!





View solution in original post

3 REPLIES 3
audreygerred
Super User
Super User

Hi! I have the following data entered:

audreygerred_0-1706899842636.png

 

In Power Query, I sorted Phone descensding so that all the Yes are above all the No. I then added an index column, and then removed duplicates on ID. VIOLA! It keeps the first instance in the list which will be Yes because of the sorting and indexing.

audreygerred_1-1706899934432.pngaudreygerred_2-1706899958726.png

 

 





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

Proud to be a Super User!





Works like a charm. Thank you so much for the help!

You're very welcom, happy to help! Have a great weekend!





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

Proud to be a Super User!





Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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