I am trying to join three tables to then create a pivot table. I'm struggling to find figure out how to do this.
Below is an example of the format of the three existing tables and the desired out output table.
I am working in Tableau and the data is feeding in from a Microsoft SQL server.
Contact Table (Table 1)
Contact ID | Name | Channel | Contact Type | Stage 1 | Stage 2 |
---|---|---|---|---|---|
12098 | Andrew | Client | 44593 | 44597 | |
34556 | Joe | Client | 44568 | 44576 | |
32344 | Paul | Indeed | Buyer | ||
32211 | Simon | Indeed | Client | 44562 | 44570 |
21212 | Peter | Client | 44599 | 44601 | |
29871 | Sam | Client | 44611 | 44613 |
Contact/Deal Association (Table 2)
Deal ID | Contact ID |
---|---|
543 | 12098 |
232 | 34556 |
456 | 32211 |
787 | 21212 |
654 | 29871 |
Deal History (Table 3)
Deal ID | Stage 3 | Stage 4 | Stage 5 |
---|---|---|---|
543 | 44599 | 44601 | |
232 | 44582 | 44593 | 44599 |
456 | 44580 | ||
787 | 44610 | 44612 | 44615 |
654 | 44615 |
Pivot Table (Output Table)
Contact ID | Pivot Name | Pivot Value |
---|---|---|
12098 | Stage 1 | 44593 |
12098 | Stage 2 | 44597 |
12098 | Stage 3 | 44599 |
12098 | Stage 4 | 44601 |
34556 | Stage 1 | 44568 |
34556 | Stage 2 | 44576 |
34556 | Stage 3 | 44582 |
34556 | Stage 4 | 44593 |
34556 | Stage 5 | 44599 |
32211 | Stage 1 | 44562 |
32211 | Stage 2 | 44570 |
32211 | Stage 3 | 44580 |
21212 | Stage 1 | 44599 |
21212 | Stage 2 | 44601 |
21212 | Stage 3 | 44610 |
21212 | Stage 4 | 44612 |
21212 | Stage 5 | 44615 |
29871 | Stage 1 | 44611 |
29871 | Stage 2 | 44613 |
29871 | Stage 3 | 44615 |
Any advise would be greatly appreciated.
Thank you.