Search code examples
tableau-apiline-plot

create line plot from table in tableau


I've got data that look similar to this

+------------+--------------+---------+---------+---------+---------+
| funding_id | amountOnHand | rate_1d | rate_1w | rate_1m | rate_1y |
+------------+--------------+---------+---------+---------+---------+
| USDOIS     |          100 |      18 |       9 |      12 |       2 |
| USDOIS     |          106 |       3 |       6 |      16 |       2 |
| USDOIS     |          103 |       1 |       7 |       5 |      15 |
| USDOIS     |          108 |       1 |      11 |      11 |      13 |
| JPYOIS     |          100 |       0 |      19 |      16 |      15 |
| JPYOIS     |          106 |       9 |      10 |      10 |       5 |
| JPYOIS     |          103 |       4 |       9 |      11 |       6 |
| JPYOIS     |          109 |       9 |      18 |      14 |       2 |
| EUROIS     |          104 |       3 |       6 |      19 |       6 |
| EUROIS     |          103 |       3 |      11 |      19 |       3 |
| EUROIS     |          104 |       9 |       1 |       8 |      15 |
| EUROIS     |          107 |      18 |       4 |       1 |       5 |
+------------+--------------+---------+---------+---------+---------+

I create weighted rates per funding id using the aggreation: SUM([rate_1d]*[initial])/SUM([initial])

And then use tableau to create a text table and get something similar to the following table (note that sometimes an entire row is null. that's ok)

+------------+------------------+------------------+------------------+------------------+
| funding_id | weighted_rate_1d | weighted_rate_1w | weighted_rate_1m | weighted_rate_1y |
+------------+------------------+------------------+------------------+------------------+
| AUDOIS     | 3.0              | 8.0              | 6.0              | 3.0              |
| CADOIS     | 20.0             | 3.0              | 17.0             | 0.0              |
| EUROIS     | 9.0              | 0.0              | 19.0             | 7.0              |
| GBP CORP   |                  |                  |                  |                  |
| GBPOIS     | 12.0             | 19.0             | 14.0             | 16.0             |
| JPYOIS     | 10.0             | 7.0              | 18.0             | 3.0              |
| USDOIS     | 19.0             | 7.0              | 5.0              | 7.0              |
+------------+------------------+------------------+------------------+------------------+

What I'd like to do is create a line plot showing time on the x axis (so 1d/1w/1m/1y) and rate on the y axis, with each line colored by funding_id

Is there any way to do this?


Solution

  • The solution is to use the "measure name" and "measure value" fields at the bottom of the "dimensions" and "measures" panels in the data selection area (no need to create a table at all)

    so the steps are:

    1) create 4 aggregations (weighted_rate_1d, etc)

    2) create a new worksheet

    3) drag Measure Names (found under Dimensions) to the Columns shelf

    4) right click it, and filter out everything except the aggregations

    5) drag "Measure Values" to the rows shelf

    6) in the "marks" area just to the left of the plot (where you can change color, shape, etc) use the drop down menu to change the bar plot to a line plot

    7) just below this, you'll see the measure values listed in green boxes- drag them around to reorder to it goes 1d, 1w, 1m, 1y (by default, 1w and 1m are switched because they're in alphabetic order)

    8) drag funding_id to the color panel