0

I have 2 data tables that I need to join together for analysis in Tableau desktop. Let's say for the sake of simplicity that one table contains height of individual persons (column per person) and another table contains weights for the same persons (again, column per person).

What I am trying to do is to join to tables on date and person, calculate weight/age ratio and group people in clusters. Can you suggest how to do that without changing the format of source data tables?

For example, let's imagine that the Height table looks like this:

Date        John  Jill
2015/08/19  180   160
2015/08/20  181   161
2015/08/21  182   160

And Weight table looks like this:

Date        John  Jill
2015/08/19  10   20
2015/08/20  10   21
2015/08/21  10   20

How do I convert these tables into something like this for subsequent group by on Date and Person?

Date        Person Height Weight
2015/08/19  John   180    10
2015/08/19  Jill   160    20
2015/08/20  John   181    10
2015/08/20  Jill   161    21
2015/08/21  John   182    10
2015/08/21  Jill   160    20
  • What flavor of SQL are you using? – Andrew LaPrise Aug 26 '15 at 22:31
  • Well that's an interesting table setup you have there. One column per person? Usually your table starts out like the third one. If you can share what database you are using we can probably give you a more targeted answer. – Sam M Aug 27 '15 at 19:58
  • The data comes from CSV files, but I can import them into any SQL-like storage of choice. Unfortunately I have no control over the format of original CSV files and there's over 100+ columns and 1M+ rows. – Dmitry Guyvoronsky Aug 28 '15 at 06:18

1 Answers1

1

I have 2 solutions for you

1) You can import data to any SQL storage and then pivot your data the way you want (MySQL example here: MySQL pivot table)

2) Using only Tableau (at least version 9.0) :

  • Connect 1st file to tableau -> and pivot it. Then rename values as "name" and 'height' enter image description here

  • Connect the second table as the second data source. Do the same with it.

  • Then drag-and-drop values from 2 data sources to the view ( if you have complex data you may need to adjust blending options) enter image description here
Community
  • 1
  • 1
Vadym B.
  • 681
  • 7
  • 21