Forum Discussion
Remove duplicates
Hello,
I have a table as per below. I need to remove duplicates so that one number of PO stays with each couple VBELN/POS, it does not really matter in which order.
I imagine this need sto be recursive, I am still not very proficient with it.... I appreciate your help!
Kind regards
Valeria
| VBELN | POS | PO |
| 80001 | 10 | 123456 |
| 80002 | 20 | 123456 |
| 80001 | 10 | 654321 |
| 80002 | 20 | 654321 |
| Result: | ||
| VBELN | POS | PO |
| 80001 | 10 | 123456 |
| 80002 | 20 | 654321 |
Hi, ValeriaBreve this works on your test data but I am not sure about real life data...
let Source = your_table, groups = Table.Group(Source, {"PO"}, {{"VP", each List.Zip({[VBELN], [POS]})}}), lst = List.Buffer(groups[VP]), vp_txf = List.Accumulate( lst, {}, (s, c) => [a = List.Difference(c, s), b = s & {List.First(a)}][b] ), z = Table.FromColumns({groups[PO], vp_txf}, {"PO", "VP"}), extract = Table.TransformColumns(z, {"VP", each Text.Combine(List.Transform(_, Text.From), "@@@"), type text}), split = Table.SplitColumn(extract, "VP", Splitter.SplitTextByDelimiter("@@@", QuoteStyle.Csv), {"VBELN", "POS"}) in split
15 Replies
- ray_aramburoSuper User
How would you determine which VBELNPOS goes with which PO?
- ValeriaBrevePost Partisan
ray_aramburo hello, it does not really matter, as long as they unique.... thanks!
- ray_aramburoSuper User
All of the lines these lines are unique considering that for each PO they have a different VBELN and POS in each row.
VBELN POS PO 80001 10 123456 80002 20 123456 80001 10 654321 80002 20 654321 If you are expecting as a result
VBELN POS PO 80001 10 123456 80002 20 654321 What is your expectation for
VBELN POS PO 80002 20 123456 80001 10 654321 - ValeriaBrevePost Partisan
Hello ray_aramburo , I understand your confusion, I made a mistake in the mock data!!!! Sorry about it. This is how it should look:
VBELN POS PO 80001 10 123456 80001 20 123456 80001 10 654321 80001 20 654321 Result: VBELN POS PO 80001 10 123456 80001 20 654321 And then it does not matter which PO goes to which POS, as long as there is one PO only for each POS and that they are unique.
Thanks!