Forum Discussion

LABORSAL's avatar
LABORSAL
Icon for Advocate II rankAdvocate II
6 years ago

Appending tables with complimentary data

Hello,

 

What I'm trying to achieve but been unable to so far is the join of 3 tables which compliment the data of each other based on a key value which must not be contained in the previous information.

 

As an example here is some dummy data (colored to make it easier to understand what's going on, middle table has 2 colors to separate the key value [Periodo] in the table)

Dummy Data

In this example the join order should be blue/orange -> yellow -> green. When the orange table (versions in the second table) is not existant this is solved by doing a right anti between blue and yellow, mixing it with blue and then repeat the process with green, however when the version is introduced this no longer works.

 

What I've already tried is to group by the key which gives me a table of middle tables (if that makes sense) but when I try to do the previous steps I end up replicating everything and duplicates show up.

 

The end table should include (for each version) all the periods from middle, add possible periods from first and then add missing periods from gree, it would look like this:

End Table