let
Table3 = Table.Distinct(Table1 & Table2),
Custom2 = Table.Repeat(Table3,100),
#"Added Index" = Table.AddIndexColumn(Custom2, "Index", 0, 1),
Grouped = Table.Group(#"Added Index", {"A1", "A2", "A3", "A4", "A5", "A6"}, {{"idx", each _[Index], type list}}),
Merged = Table.Join(#"Added Index", {"A1", "A2", "A3", "A4", "A5", "A6"}, Grouped, {"A1", "A2", "A3", "A4", "A5", "A6"}),
a = Table.AddColumn(Merged, "Duplicated", each [
a = Table.FromColumns({List.RemoveMatchingItems([idx],{[Index]})},{"a"}),
b = Table.AddIndexColumn(a, "b"),
c = Table.Group(b, {"a","b"},
{{"c",
(_)=>let
rc = Table.RowCount(_),
aa = if rc=1 then [a] else List.RemoveRange([a],1,rc-2),
d = if rc=2 then "," else "-"
in
Text.Combine(List.Transform(aa,Text.From),d), type text
}},0,
(a,b)=>if b[a]-a[a]>b[b]-a[b] then 1 else 0
),
d = Text.Combine(c[c],",")
][d])
in
a |