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
Opal55
Helper II
Helper II

Conditionally remove duplicates in one column

Not sure how to do this.  I have one column in a table that has duplicate values that I want to remove in the Power Query Editor, but there are some duplicates that I need to keep.   The column contains work order numbers and is downloaded out of SAP.  I want to remove all of the duplicate work orders, BUT, some records have a "#" assigned as the work order number and those will be duplicated as well and I don't want to remove those.  All I have been reading is how to remove duplicates based on values in other columns, but that is not the case here.  Any suggestions?  Thank you.

1 ACCEPTED SOLUTION
mattww
Responsive Resident
Responsive Resident

Sorry if I didn't explain it well

 

So you would split your query.

 

Query A = All of your data

Query B = Reference Query A, filter to only include those starting with #

Query C = Reference Query A, filter to only include those not starting with #, remove duplicates

Query D = Append Query B and Query C

 

The above could all be done in one query via the Advanced Editor, but if you prefer to do it via the GUI, just separate out the queries and to avoid them cluttering up your model, set queries A, B and C to not load (right click the query and untick Enable load)

 

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

 

Matt

View solution in original post

5 REPLIES 5
v-shex-msft
Community Support
Community Support

Hi @Opal55,

Can you please share a pbix or some dummy data that keep raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

@mattww suggestion worked!  Thank you all!

Opal55
Helper II
Helper II

Sorry... I am confused by your suggestion.  If I filter out the the Work Orders that do not have a "#" and then remove the duplicates, all of the duplicated records containing a "#" are removed as well...  I just tried it.

mattww
Responsive Resident
Responsive Resident

Sorry if I didn't explain it well

 

So you would split your query.

 

Query A = All of your data

Query B = Reference Query A, filter to only include those starting with #

Query C = Reference Query A, filter to only include those not starting with #, remove duplicates

Query D = Append Query B and Query C

 

The above could all be done in one query via the Advanced Editor, but if you prefer to do it via the GUI, just separate out the queries and to avoid them cluttering up your model, set queries A, B and C to not load (right click the query and untick Enable load)

 

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

 

Matt

mattww
Responsive Resident
Responsive Resident

You could filter your table based on having an work order number that does not start with #. Remove the duplicates

 

Separately, filter the same table where work order does start with #

 

Then append the two together

 

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

 

Matt

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.