1
votes

I am new to Tableau visualization and need some help.

I have a set of shipping lanes which have whole numbers values based on the duration for the shipment. Ex:

| Lane Name | 0 Day | 1 Day | 2 Day | 3 Day | 4 Day |
|  SFO-LAX  |    0  |    30 |    60 |    10 |     0 |
|  JFK-LAX  |    0  |    10 |    20 |    50 |    80 |

For each Lane Name, I want to return the column header based on the max value. i.e. for SFO-LAX I would return '2 Day', for JFK-LAX I would return '4 Day', etc. I then want to set this as a filter to only show 2 Day and 3 Day results in my Tableau data set.

Can someone help?

1

1 Answers

1
votes

Two steps to this.

The first step is pretty easy, pivot your data. Read the Tableau help to learn how to PIVOT your data for analysis - i.e. make it look to Tableau as a longer 3 column data set with Lane, Duration, Value as the 3 columns. Tableau's PIVOT feature will let you view your data in that format (which makes analysis much easier) without actually changing the format of your data files.

The second step is a bit trickier than you'd expect at first glance, and there are a few ways to accomplish it. The Tableau features that can be used for this are LOD calcs, table calcs, filters and possibly sets. These are some of the more powerful but complicated parts of Tableau, so worth your time to learn about, but expect to take a while to spin up on them.

The easiest solution is probably to use one of the RANK() function - start as a quick table calc. Set your partitioning and addressing as desired so that the ranks are computed for the blocks of data that you desire - say partitioning on Lane and addressing or computing by Duration. Then when you are happy with the ranks you see, move the rank calculation to the filter shelf and only display data where rank = 1.

This is a quick solution once you get the hang of it, but it can get slow for very large data sets since the rank calculations are done on the client side, requiring fetching all the data that you end up not displaying. If performance becomes an issue, you might want to look at other solutions to do more of the calculations server side - possibly using LOD calcs or analytic aka windowing queries invoked from custom SQL