Hello,

I’m trying to do a certain transformation and I’m not sure how to tackle it. The origin table is a list of pairs of equivalences, which take place between two codes:

In equivalence “1”, code 1 “IT4510” is equal to code 2 “DE4510”, in equivalence “2” code “IT4510” is equal to code 2 “UK9.48” and so on.

If “IT4510” is equal to both “DE4510” and “UK9.48”, this means that “DE4510” and “UK9.48” are also equal to each other. If we look at equivalence “4”, we can see that code 1 “ES5933” would also join this group, as it is equivalent to “UK9.48”.

Equivalence “3” however contains two codes that do not appear in any of the other lines, so in this case there’s no more cross-equivalences to make.

The desired output table shows the total “global equivalences” that really occur in all these pairs of equivalences. It would look like this:

In total, there are 3 “global equivalences”, because all the cross-equivalences seen in the origin table are taken into account and linked together, and each unique code only appears once now. Note that both codes of equivalence “8” of the origin table are already included in global equivalence “1”.

I think the solution involves iterating each row, but the iterated row needs to have other multiple rows into account in order to obtain the global equivalence, and that’s where I’m stuck.

Thanks very much,

Roberto