Power Query - Keep duplicates

pepe74287

New Member
Joined
Feb 4, 2015
Messages
43
Hello, is there a way in Power Query to keep duplicate values only? I'm trying to achieve the exact opposite of Remove duplicates (so all unique records and first occurrence of duplicated record is removed). In other words, if I have this dataset:

a
b
a
a
a
c
c


After I remove duplicates I get:

a
b
c

And what I'm after is:
a
a
a
c


Thanks a lot in advance.

Pepe
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Easiest would probably to group the data on the column, with operation: "All rows".
This chunks the source up into the rows per column entry. If you nest in a Table.Skip(_, 1), this will delete the first row of each group (this being the result of the remove-duplicates-operation). Then expand the table again:

= Table.Group(Source, {"YourColumn"}, {{"KeptDups", each Table.Skip(_, 1), type table}})

LinkToFile
 
Last edited:
Upvote 0
First off, Imke is my hero. But could you: "Group by" your field and count the rows field, then just do a simple filter of >1 in that count field?
 
Upvote 0
: -)
Almost - as this would return all letters that contain duplicates. So including their first entry (4 a's and 2c's in this example)
But the request was a bit different, as all first occurrences should be removed. (3 a's and 1c remaining).
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,154
Messages
6,176,731
Members
452,740
Latest member
MrCY

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top