Find Duplicates in a Column (No Group By)

donkey shrek

New Member
Joined
Nov 15, 2022
Messages
26
Office Version
  1. 365
Platform
  1. Windows
I want to identify duplicates in column RandomColumn without using Group By - as this method will drop unused columns

Power Query:
= let columnNames = {"RandomColumn"}, addCount = Table.Group(#"Added Index", columnNames, {{"Count", Table.RowCount, type number}}) in Table.AddColumn(#"Added Index", "TESTICLES", if Table.SelectRows(addCount, each [Count] > 1) then "Duplicate" else "OK")
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Something like this?

Duplicates
ABCD
1ValuesValuesDupCheck
2AA
3BB
4CC
5CCDuplicate
6DD
7EE
8FF
9FFDuplicate
10GG
11HH
Sheet4


Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Duplicates = List.Accumulate(Source[Values],{},(s,c)=> if List.Contains(s,c) then s & {"Duplicate"} else s & {c}),
    Index = Table.AddIndexColumn(Source, "DupCheck", 0, 1, Int64.Type),
    TX = Table.TransformColumns(Index,{{"DupCheck", each if Duplicates{_}="Duplicate" then "Duplicate" else null}})
in
    TX
 
Upvote 0
Something like this?

Duplicates
ABCD
1ValuesValuesDupCheck
2AA
3BB
4CC
5CCDuplicate
6DD
7EE
8FF
9FFDuplicate
10GG
11HH
Sheet4


Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Duplicates = List.Accumulate(Source[Values],{},(s,c)=> if List.Contains(s,c) then s & {"Duplicate"} else s & {c}),
    Index = Table.AddIndexColumn(Source, "DupCheck", 0, 1, Int64.Type),
    TX = Table.TransformColumns(Index,{{"DupCheck", each if Duplicates{_}="Duplicate" then "Duplicate" else null}})
in
    TX
Thank you! That works well. How about if ALL instances of F and C state "Duplicate", rather than just the 2nd occurrence of them?
 
Upvote 0
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    lst = List.Buffer(Source[Values]), 
    tbl = Table.AddColumn(Source, "DupCheck", each if List.Count(List.Select(lst, (x)=> x = [Values]))>1 then "Duplicate" else "")
in
    tbl
 
Upvote 0
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    lst = List.Buffer(Source[Values]),
    tbl = Table.AddColumn(Source, "DupCheck", each if List.Count(List.Select(lst, (x)=> x = [Values]))>1 then "Duplicate" else "")
in
    tbl
Thanks! This works but only when the list matches exactly. How about if just any given element in is found in any other list, then they will all be marked duplicate?
 
Upvote 0
Not sure what you're asking. Can you post sample data and what the results table should look like for that sample?
 
Upvote 0
I want all lists to be able to compare against each other, to check for any similar values

Something like:
For Each List in [ListofDateTimes]
if List.ContainsAny(CurrentList, [ListOfDateTimes])
then "Yes" else "No"

1673631424907.png
 
Upvote 0
Power Query:
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText(
        "XVFJDsQgDPtLz1XUEsDJWxD//8agiiWeG5EdL6S1K2dXl+RvxXV/UxWU+YTkt24AUvKhueAx1TmZ4JPod5vzwDY6Nk0DNxcL2LAI5k9gLo+lyqhRbNaBpLIl6377JB1BXlKN8rHgsKbyKWA+P2apQpwKxrpcASEbyGGVO0lBjraPZJSFG5mUv+P1/gM=", 
        BinaryEncoding.Base64), Compression.Deflate))),
    ChangedType = Table.TransformColumnTypes(Source,{{"Column1", type number}, {"Column2", type number}, {"Column3", type number}, {"Column4", type number}, {"Column5", type number}, {"Column6", type number}}),
    tbl = Table.TransformColumnTypes(ChangedType,{{"Column1", type datetime}, {"Column2", type datetime}, {"Column3", type datetime}, {"Column4", type datetime}, {"Column5", type datetime}, {"Column6", type datetime}}),
    lst = Table.ToColumns(tbl),
    tbl2 = Table.FromList(lst, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    tbl3 = Table.AddIndexColumn(tbl2, "Index", 0, 1, Int64.Type),
    lst1 = List.Zip({tbl3[Column1], tbl3[Index]}),
    tbl4 = Table.AddColumn(tbl3, "Overlap", each List.Accumulate(lst1, "", (s,c)=> if List.ContainsAny([Column1], c{0}) then s & Text.From(c{1}) & "," else s)),
    tbl5 = Table.FromRecords(Table.TransformRows(tbl4, each Record.TransformFields(_, {"Overlap", (x)=> Text.Replace(x, Text.From(_[Index]) & ",", "")}))),
    Result = Table.TransformColumns(tbl5, {"Overlap", each Text.Start(_, Text.Length(_) -1 )})
in
    Result
 
Upvote 0
Solution
Power Query:
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText(
        "XVFJDsQgDPtLz1XUEsDJWxD//8agiiWeG5EdL6S1K2dXl+RvxXV/UxWU+YTkt24AUvKhueAx1TmZ4JPod5vzwDY6Nk0DNxcL2LAI5k9gLo+lyqhRbNaBpLIl6377JB1BXlKN8rHgsKbyKWA+P2apQpwKxrpcASEbyGGVO0lBjraPZJSFG5mUv+P1/gM=",
        BinaryEncoding.Base64), Compression.Deflate))),
    ChangedType = Table.TransformColumnTypes(Source,{{"Column1", type number}, {"Column2", type number}, {"Column3", type number}, {"Column4", type number}, {"Column5", type number}, {"Column6", type number}}),
    tbl = Table.TransformColumnTypes(ChangedType,{{"Column1", type datetime}, {"Column2", type datetime}, {"Column3", type datetime}, {"Column4", type datetime}, {"Column5", type datetime}, {"Column6", type datetime}}),
    lst = Table.ToColumns(tbl),
    tbl2 = Table.FromList(lst, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    tbl3 = Table.AddIndexColumn(tbl2, "Index", 0, 1, Int64.Type),
    lst1 = List.Zip({tbl3[Column1], tbl3[Index]}),
    tbl4 = Table.AddColumn(tbl3, "Overlap", each List.Accumulate(lst1, "", (s,c)=> if List.ContainsAny([Column1], c{0}) then s & Text.From(c{1}) & "," else s)),
    tbl5 = Table.FromRecords(Table.TransformRows(tbl4, each Record.TransformFields(_, {"Overlap", (x)=> Text.Replace(x, Text.From(_[Index]) & ",", "")}))),
    Result = Table.TransformColumns(tbl5, {"Overlap", each Text.Start(_, Text.Length(_) -1 )})
in
    Result
You're amazing! Thank you so much!
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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