Playing with Parameter Actions: Tableau 2019.2


Playing with Parameter Actions
In Beta 2019.2

I recently downloaded the Beta version of Tableau 2019.2 and there are some serious gems in this version.  It’s gonna be HUGE!  One of the new features is Parameter Actions of which I’ve spent quite some time playing with.  In this blog post, I’ll share some potential ideas for using them.

Continual Additions to Workbook & Blog

Before moving on, please note a few things.  First, I intend to continually add to this blog post and to the associated Tableau Workbook (download it to follow along) so that all my personal work with parameter actions can be accessed in one spot.  I hope that you'll check back often to see what new things have been added.  Also because of that, this blog post might be a bit lengthy.  Each section is labeled and has a GIF associated with it (the header GIF above only contains some of them).  I recommend that you scroll through the blog post, review each GIF, find ones you are interested in and review those.  If you are not interested in a certain one, just skip it.  

To make all of this much easier, I will be providing a short table of contents below.  

Table of Contents

1. Change Line Color & Size
2. Add Label with Hover
3. Lollipop with Detail
4. Change Shape & Add Label
5. Change Shape & Color for Related Dimension
6. Chart Swap with Buttons
7. Sliding Reference Line with Value
8. Highlight Past Date in Area or Line Chart
9. Highlight Running Sum from Date
10. Background Color Picker
11. Drill Down Bar Chart
12. Drill Down Scatter Plot
13. Map Toggle
14. Compare Bar Sizes
15. Make Paths with "Make Line"


What is a Parameter Action?

Before getting to the details, let's discuss what a parameter action does.  A parameter action is similar to a filter or highlight action in that it is activated by interacting with the viz itself.  In doing so, you are able to change the parameter value.  So all the cool things you could do with a parameter previously can be done simply by interacting with the viz itself.  This provides a ton of flexibility.

I should also note that there were several people in the community that really crushed it with set actions (released in 2018.3 in October), Lindsay Poulter and Bethany Lyons to name just a couple.  A lot of the parameter action examples I provide in this post could be done with set actions and to be perfectly honest, many, if not all, probably already have.  Thank you to all that paved the way using set actions.  

In my opinion, there are four major differences to how set actions and parameter actions can be used: 1) Set actions allow for action on multiple selections where parameter actions are specific to one selection.  2) With parameter actions, you can essentially use data that is not in your data source.  3) Parameters can be used across multiple data sources, which I believe will be it's biggest benefit. 4) And finally, I personally believe that parameters are more commonly used than sets and because of that, parameter actions will be much more intuitive to the most Tableau users.

Okay, let’s talk about a few examples.  To be frank, I clearly see the use case with many of these and with others, not so much.  Perhaps those use cases exist and hopefully others can put these examples to good use…or we can just chalk it up to a little bit of fun with Tableau (which is rarely a bad thing). 

All of these examples will utilize Super Store data.  As mentioned, I recommend that you download my workbook containing these examples so that you can follow along.  

1. Change Line Color & Size


A common use of a parameter is to allow a user to highlight a specific line in a group of line charts.  We can now do this using a parameter hover action. 

Put Month of Order Date (continuous) on columns, Sum of Sales on rows, and Sub-Category on Detail.  Create a parameter called Sub-Category Parameter.  Make the parameter a string data type and allow all values.

Create two calculations:

Highlight Line Color:
IF [Sub-Category] = [Sub-Category Parameter] THEN 'RED'
ELSE 'GRAY'
END

          Highlight Line Size:
                   IF [Sub-Category] = [Sub-Category Parameter] THEN 5
ELSE 1
END

Both of these calculations are simply saying that if the sub-category is equal to the sub-category selected in the parameter, then do something.  For color, it will use red versus gray; for size, it will use 5 instead of 1 (it will make it larger). 

Add Highlight Line Color to the color card.  Change the colors of red to be red and Gray to be some color close to the background.  Add Highlight Line Size to the size card. 

Go to Worksheet and choose Actions (if you were on a dashboard, then you would go to Dashboard then choose Actions, but they work similarly whether on a sheet or dashboard).  This will bring up a window that you are probably very familiar with already.  In this window, choose Add Action and choose Change Parameter.  Name the action (I used Highlight Line).  In Source Sheets, it should appear blank if using as a worksheet action.  However, if creating a dashboard action, check only the sheet that you want to allow to interact with to control the parameter.  Next choose your target parameter, the one you want to update, which is the Sub-Category Parameter.  In the Field drop-down, choose the field that will be used to update that parameter, Sub-Category (Sample Superstore).  Finally, change the action to run on Hover.



Click OK then OK again.  Now when you hover over a line, it will change the parameter to be equal to the sub-category you hovered over.  In doing so, your calculations will turn that line red and make it thicker.

The parameter is doing the same exact thing it would using a parameter drop-down menu, but you are now simply hovering to force the selections for you.

As a side note, when published, "Hover" actions cause a bit of a "flash" on screen.  In many cases, it may be best to utilize "Select" instead of "Hover.  

Note: moving forward, I will not go into detail on how to set up the parameter actions in the Add Action window, I will simply show a screenshot of that window.  They are very easy as you simply choose the source sheet, the parameter to update, and the field that will cause the update.  (Remember that if setting them up as worksheet actions, Source Sheets will remain blank there is only one worksheet). 

2. Add Label with Hover


The intention of this chart is to simply show the label when you hover over a bar.  Create a calculation called Week of Order Date: 

          DATETRUNC('week', [Order Date])

Place this new field on columns as a continuous date and choose Week.  Place Sum of Sales on rows.  This will give you a bar chart.  

Create a parameter called Order Date Parameter.  Set it as a Date data type and allow all values.  It is basically open to accept any date.

Create a calculation that looks at the week of the order date on the bar chart and matches is to the week of the Order Date Parameter.  When the two match, it will show the label and when they don’t, it will be null.  Call the calculation Label Bar Chart:

IF (DATETRUNC('week', [Order Date])) = (DATETRUNC('week', [Order Date Parameter]))
THEN [Sales]
ELSE NULL
END

Place that calculated field on Label (and adjust the label formatting as you wish).  Now create a dashboard parameter action (shown below is structured as a worksheet action):


When finished, you should be able to hover over each bar to reveal its label.  

3. Lollipop with Detail


This one is quite simple.  We will set up this lollipop chart to provide additional context via a larger shape and label when we hover over it.

Create a standard lollipop chart.  Place Sub-Category on the Rows, Sum of Sales on Columns, then duplicate Sum of Sales and make it a dual axis (be sure to synchronize your axis).  Make the first axis a bar chart, make the color gray and set the size to be very small.  On the second axis, change it a shape and choose a filled circle. 

In this example, we will use the same Sub-Category parameter from the first exercise (string and all values allowed).  

Create the following calculations:

          Sub-Category Size & Color
                   IF [Sub-Category Parameter] = [Sub-Category] THEN 5
ELSE 1
END

          Sub-Category Label
SUM(IF [Sub-Category Parameter] = [Sub-Category] THEN [Number of Records]
ELSE NULL
END)

Both calculations will determine if the sub-category equals the parameter.  The first calculation will list a 5 for true and a 1 for false (we will use this for both color and size).  The second calculation will sum the number of records for true and provide a null value for false.

Add Sub-Category Size & Color to both Color and Size.  Change the colors to whatever colors you like; I used blue for 1 and green for 5.  Size it however you like.  Now add the Sub-Category Label field to the Label card.

Set up a parameter action using the Lollipop sheet, to update the Sub-Category Parameter, using the Sub-Category field. 


Now when you hover over any bar or label, it will increase the size of the circle and show the number of records inside of that circle. 

4. Change Shape & Add Label


In this example, hovering over a point on a scatter plot will change the shape and add a label.  For my example, I created a custom shape, but you could just change the shape to one of the standard shapes or create your own.

Put Sum of Sales on columns and Profit Ratio on rows.  Then add State to detail. 

Create a parameter called State Parameter.  Change it to a string data type then use the Add from Field button to populate the parameter with the State field.  Add a value at the end of the data set called NONE. (You will be able to use NONE to clear the selection.  We will talk about this again a bit later).

Create three calculations:

          Shape Change for State
                   IF [State] = [State Parameter] THEN 'Shape'
ELSE 'Circle'
END

Shape Size for State
IF [State] = [State Parameter] THEN 10
ELSE 0
END

          Shape Label for State
IF [State] = [State Parameter] THEN '                                                         ' + [State]
ELSE NULL
END

All of these calculations will compare the actual state in the scatter plot to the state parameter.  If they match, the first will change the shape, the second will change the size, and the third will add a label.  Notice on the label calculation, I added spaces to help line up the label to my shape.  If you use a different shape, you may not need these spaces.

Change the chart type to be Shape.  Place the Shape Change for State field on Shape then edit the shapes to be whatever you choose.  In my case I used a custom shape I created and a circle.  Next, place the Shape Size for State field on Size and adjust to your preference.  Finally, place Shape Label for State on Label and edit font sizes and/or colors. 

As the final step, create a parameter action:



Now when you hover over a point, it will change shape, become larger, and a label will be shown. 

5. Change Shape & Color for Related Dimension


This chart shows Profit vs. Sales for each Order ID / Sub-Category.  When we are finished with it, when you hover, it will highlight all other Order IDs in the same Sub-Category. 

Put Sum of Profit on columns and Sum of Sales on rows.  Put Order ID and Sub-Category on detail.  We will once again use the Sub-Category Parameter we utilized previously. 

In this example, we are going to create just one calculation (like the parameter, you should have already created this calculation in the Lollipop example above).  Call it Sub-Category Size & Color:

IF [Sub-Category Parameter] = [Sub-Category] THEN 5
ELSE 1
END

Place this field on both size and color.  Change the colors to be what you like.  In my example, 5 was set to orange and 1 set to blue. 

Now add a parameter action as follows (remember I’m using a worksheet action):


Now when you hover over a point, it will highlight other orders in the same sub-category.

6.  Chart Swap with Buttons


A chart swap can be done using two or more sheets and a parameter.  In my opinion, the best article on how to do this is from Hashu Shenkar on the Data School blog site.  The one issue is that this uses a parameter drop-down menu for selecting the chart.  I would prefer a more user-friendly experience using buttons.  Matt Chambers wrote about an ingenious way to utilize buttons to make these swaps. With parameter actions, this job became much more simple as you don't need to perform any joins that significantly increase the size of your data. 

Build a viz using the steps listed in the aforementioned blog post (you will have two sheets on a dashboard with a parameter to toggle between the two).  I used a scatter plot and an area chart with a parameter called Area or Scatter. 

Next, create some buttons using icons to represent your different charts.  In my example, I used an image of a scatter plot and one of an area chart (we will use that as an example moving forward).  Create a new Excel spreadsheet with three columns:  Type, X, Y.  List the two chart types you want to swap under Type and make sure they match the chart types listed in your parameter.  Your buttons will be placed next to each other on an X / Y plane, so list coordinates that allow you do this.  I used 1, 1 and 2, 1.   Save the spreadsheet as Button Data.


Add a new sheet called Buttons.  Add this Button Data spreadsheet as a new data source in Tableau.  On this sheet, add X to columns, Y to rows, change the mark type to Shape, then add Type to the Shape card.  Assign the two shapes you created previously to these points.  You should have something like this:


Add this Buttons sheet to the dashboard you previously created for the sheet swap.

Lastly, set up the parameter action (in this case, a dashboard action) so that the Buttons sheet changes the Area or Scatter parameter using the Type field from the buttons spreadsheet.


Now when you click on the button corresponding to the scatter plot, it will update the parameter to be scatter and the chart swap will occur.  The same thing will happen when you click the area chart button. 

7. Sliding Reference Line with Value


This chart allows you to hover over the chart, show a reference line where hovering and reveal the sales value at the top of that reference line (note the GIF is a bit delayed).

Create an area chart with continuous Month of Order Date on columns and Sum of Sales on rows.  We will use the same Order Date Parameter we used previously for the lollipop chart (date with all allowable values).  

In order to show the label at the top each time, we need to create a second axis.  Next to Sum of Sales, just double-click and type avg(100000) (for this example, I am hardcoding this number in.  Normally I would suggest an LOD to fix it at a max height, but for now, let's keep it simple and just hardcode in a number that is above the maximum value in your chart).  Change this axis to a line and bring the opacity to 0 so it cannot be seen.  Ultimately, we will label this line so that the labels remain in the same position.

Create a calculation called Sales Label for Slider and use the following for the calculation:

IF (DATETRUNC('month', [Order Date])) = (DATETRUNC('month', [Order Date Parameter]))
THEN [Sales]
ELSE null
END

Basically this is saying that when the month of order date on the chart equals the month of the order date parameter, then show Sales.  Add this calculation to the Label card of the second axis (the transparent line). 

Finally, add a reference line to the Entire Table.  Set the value to be the Order Date Parameter, the label to be the Value and you can modify the line style as you wish.


Now add your parameter action as follows:


Once this is complete, you should be able to hover over the area chart to show a reference line with the date value at the bottom and the sales value at the top (and in the same location each time).

8. Highlight Past Date in Area or Line Chart


In this example, we will simply set the chart to highlight dates before the cursor in one color and after the cursor in another color.  This is certainly one of those examples with potential, but is also potentially useless J

Place Month of Order Date on columns as a continuous value and place Sum of Sales on rows.  Change the chart type to an Area chart.  For this example, we will use the same Order Date Parameter we used in the last exercise.  

Create a calculation called Highlight Area Chart:

IF (DATETRUNC('month', [Order Date])) <= (DATETRUNC('month', [Order Date Parameter]))
THEN 'BLUE'
ELSE 'GRAY'
END

As all the others do, this will match our field to the parameter.  In this case, if the month of the order date is less than or equal to the month of the order date parameter, we will highlight the area chart one color and if not, then it will highlight in another color. 

Place this field on color and change the colors to be whatever you like.  I used blue and a dark gray. 

Now create your parameter action:


Now take your cursor and slide it slowly over the area chart.  The dates to the left of your cursor will highlight in one color and all other dates in another color.

9. Highlight Running Sum from Date


This is very similar to the area chart above, but this is using a running sum and will highlight running sum values from that point forward. 

In this chart, we are going to use week instead of month.  We will use the same Week of Order Date that we previously created.  We will also use the Order Date Parameter we previously created.  

Place Week of Order Date on columns as a continuous date and choose Week.  Place Sum of Sales on rows.  Change that to a bar chart if it isn’t already.  Duplicate the Sales pill and change it to a quick table calculation as a running total.  Next, turn it into a dual axis and synchronize the axes.  In my case, I also added Week of Order Date to the filter in order to trim down the data a bit.  Your view should look something like this:


Create a calculated field called Highlight Area Chart with Running Sum:

IF (DATETRUNC('week', [Order Date])) <= (DATETRUNC('week', [Order Date Parameter]))
          THEN 'BLUE'
ELSE 'GRAY'
END

Similar to the area chart above, this will compare the week of Order Date to the week of the Order Date parameter.  If it’s less than or equal to the parameter, it will highlight in one color and if greater than, it will highlight in another color. 

Place this calculated field on Color.  Change the colors to your liking.  I chose a dark blue and dark gray.  Now add your parameter action:


Now take your cursor and slide it slowly over the bar chart.  The running sum associated with dates to the left of your cursor will highlight in one color and ones in the future will highlight in another color allowing you to quickly see future projections from any point in time.

10. Background Color Picker


With parameter actions, you can easily create a background color picker in just a few steps.  Several others have written about how to change the background color with a parameter, including Ken Flerlage, but I will be leveraging the trick provided by Pradeep Kumar on Rajeev Pandey's website.  With parameter actions, this becomes so much more powerful.  

Create a spreadsheet that will contain your colors.  I used the following so that I could create a 12-color color wheel:

Color
Yellow 1
Yellow 2
Orange 1
Orange 2
Red 1
Pink 1
Purple 1
Blue 1
Blue 2
Blue 3
Green 1
Green 2

Save the spreadsheet as Color Wheel.  Open a new Tableau sheet and call it Color Picker Background then connect to the spreadsheet as a new data source. 

Create a new Parameter called Color Picker as a data type of string and allowable values of list.  Use the Add from Field option to bring the colors from your spreadsheet into your parameter list.

Under the marks cards, double click and just type 1 and enter.  You should see SUM(1) be added to detail.  Now drop the Color Picker parameter on Color and change the mark to be a square.  Make the size as large as possible.  At the top, change from Standard view to Entire View.  Your square should now cover the entire screen.  Finally, remove the title.  Using the Color card, change the colors to match the colors in the parameter. 

On a new sheet called Color Picker (connected to that same data source), create a pie chart using these colors.  To create a pie chart, I typically start with a bar chart then turn it into a pie. Put Color on Rows then Number of Records on Columns.  Go to Show Me and change it to a pie.  (I feel so dirty advising someone to turn a bar chart into a pie chart using Show Me.  I rarely advocate for either pies or Show Me). You should now have a pie with 12 equal slices.  Using the Color card, change the colors of each slice to match the colors in the list (same as before).  Add a white border to the pie chart as well.  Change the background to be transparent.  

Create a dashboard.  Float the Color Picker Background worksheet onto the dashboard and change its size to cover the entire dashboard.  Now float your Color Picker sheet on top. 

Finally, go to Dashboard and add a parameter action as follows:



Now when you hover over the color wheel (Color Picker sheet), it will change the background color.  

11. Drill Down Bar Chart



This view will allow us to drill down into the bar chart to display a stacked bar chart of it's sub-categories.

Create a Parameter called Category Parameter.  Make it a string and a list.  Then use the Add from Field option to add in a list using the Category field.  Before closing, add a value of NONE to the bottom of the list.  

Create a sheet called Drill Down Bar Chart.  Place Category on Rows and Sum of Sales on Columns.  Create a calculation called Category to Sub-Category Drill Down:


IF [Category Parameter] = [Category] THEN [Sub-Category]

ELSE [Category]
END

Place this calculated field on color.  

For this view, we will be drilling down, but will need a way to clear the selection.  That is what the NONE value in the parameter will be for.  But when using parameter actions, we will need to click something to make that happen.  So, create a new sheet called NONE Button (we will be using the word none for clarity, but you could call it clear sheet or something like that).  Create a calculated field called None with the calculation of' 'NONE' (just like in the parameter).  Add that field to Text and center it both vertically and horizontally.  Next change the chart to Shape and choose the unfilled circle.  You should now show a circle with the word NONE in the middle.  

Now add both the Drill Down Bar Chart sheet and the None Button sheet to a new dashboard.  You will need to create two parameter actions, one for the bar chart and one for the none button. They should look like the following:




You will now be able to click on any of the bars to break them into a stacked bar showing subcategories and then click the NONE button to clear the selection.

As a side note, I believe that set actions are a better option for these types of drill downs as set actions allow you to "Remove all values from a set" when clearing the selection.  This is not currently an option with parameters, which is why this additional NONE button is required.

12. Drill Down Scatter Plot



This will be very similar to the drill down bar chart.  The chart shows sub-categories and clicking on a point drills into the individual products.  

Create a sheet called Drill Down Scatter Plot.  Place Sum of Sales on Columns and Profit Ratio on Rows.  

Create a parameter called Sub-Category Parameter for Scatter.  Set it to a String and List.  Use Add from Field to bring in a list of Sub-Categories.  At the bottom of that list, add NONE as an option. 

Create two calculated fields:


Product Drilldown from SubCategory
IF [Sub-Category Parameter for Scatter] = 'NONE' THEN [Sub-
Category]
ELSE [Product Name]
END

        Product Drilldown from SubCategory Filter
IF [Sub-Category Parameter for Scatter] = [Sub-Category] THEN 'TRUE'
ELSEIF [Sub-Category Parameter for Scatter] = 'NONE' THEN 'TRUE'
ELSE 'FALSE'
END

The first calculation will be used to drill down when you click on a point.  When you click on a Sub-Category, it will be added to the parameter and it will then use Product Name.  The second calculation will be used to filter out everything except what has been selected.  

Place Product Drilldown from SubCategory on Color.  Place Product Drilldown from SubCategory Filter on Filter and allow for only TRUE values.  

Create a dashboard and add this sheet to the dashboard.  We are going to leverage the None Button sheet we just created, so add that to the dashboard as well.  

As the last step, we need our parameter actions...again, we will use two:




Now when you click on a point, it will shift the view to product name for that sub-category.  Then simply click the NONE button to clear the selection. 

13. Map Toggle



You can easily set up your map to toggle between showing just state and showing both state and city. 

First, let's create our buttons.  Create a new Excel spreadsheet called Map Drill Down.  Create a column called Map Drill Down and populate it with two values: State and City.  In my spreadsheet, I also listed X & Y coordinates so I could control the placement of our buttons.  I listed the State at 1, 3 and City at 1, 1 (this will stack them vertically).  Create a new worksheet in Tableau called Map Buttons and add this spreadsheet as your data source.  Place X on Columns and Y on Rows.  Then place Map Drill Down on Label then center your labels.  Change your chart type to a shape and choose a circle.  You should now have two circles labeled as state and city.  These will be used for our buttons.  (Note, you could certainly use custom shapes here as well).

Now, let's create our map on a new sheet.  Call the sheet Map Toggle.  Place Country and State on detail.  Then place Sum of Sales on Color (I also reduced the opacity).  Duplicate one of the green lat or long pills to create another map and make it a dual axis.  For now, leave the dimensions as they are. 

Create a parameter called State or City.  It should be a string and allow all values.  Then create a calculated field called Map Drill Down:


IF [State or City] = 'City' THEN [City]

ELSE NULL
END

This calculation says that if the parameter equals City then use city in the map.  If not, then don't show anything.  

Click on the icon to the left of the Map Drill Down calculated field and change it to a geographic role of City (this is key).  Place that on the detail card for the second axis.  Change the mark type on that axis to be a circle and move the Sum of Sales from Color over to Size (then size as you like).  

Now, create a dashboard and add your map and your buttons.  Then create a parameter action:


Now click on the City button and it will show the cities on your map.  Click on the State button and it will show only the States.

14. Compare Bar Sizes


This chart allows the user to hover over any given bar to show the differences between that bar and all other bars.  It will do so by color coding the values larger than that value and by providing a label.  By hovering, you are able to quickly determine the differences in bar lengths.  

This view is a bit more complicated than others.  In order to make this view happen, you need to create a column that contains values for the selected bar value and for the value above that selected bar (assuming it is larger - more to come on that).  In order to do that, we will need two values associated with each row of data and because of this, will need to duplicate our data.  (Please note that this could have an impact on other portions of your visualization, calculations, etc.). 

First, create a new worksheet and connect to a new data source.  Choose Super Store (Orders should automatically show in the data pane).  Select Orders from the available data sources and drag it over to union it with your current Orders data set.  This will duplicate your data. When duplicating your data, Tableau will automatically create a calculated field called Table Name associated with each table you unioned.  In our case, the first will be called "Orders" and the second "Orders$".

Okay, go back to the worksheet and build your original view.  Put Sub-Category on Rows and Sum of Sales on Columns.  Now create a parameter called Sales Parameter.  Make it a Float data type and allow for all values.  Show the parameter.  

Now lets's create a couple of calculations:

Table Value:
IF [Table Name] = 'Orders' THEN 0
ELSE 1
END

Value Above Selected:
SUM([Sales]) - [Sales Parameter]

Break Values:
IF AVG([Table Value]) < 1
THEN 
    (IF avg([Sales Parameter]) <= SUM([Sales])
    THEN avg([Sales Parameter]) 
    ELSE SUM([Sales])
    END)
ELSE 
    (IF [Value Above Selected] > 0 THEN [Value Above Selected]
    ELSE 0
    END)
END

Break Values Label:
IF SUM([Table Value]) > 0 AND [Break Values] > 0
THEN [Break Values]
ELSE NULL
END

Okay, what are these calculations doing.  Well, we are going to need to use different values for the different tables we unioned, but eventually we will run into the issue with not mixing aggregate and non-aggregate values.  So, we are essentially going to turn this into an aggregate value with this calculation.  Any aggregation of 0 will be associated with Orders and any above that will be associated with Orders$.  

The second calculation just looks at the difference between the Sum of Sales for each bar and the selected bar value (in the parameter).

The third calculation looks at the value from the first calculation to determine if it is the sum of zeros or the sum of a bunch of 1's.  It will do something different for each.  I won't explain every detail, but it will compare the sum of sales for each bar to the bar you selected.  If a bar is larger than then one you selected, then this calculation will create a value equal to the bar you selected  (for "Orders") and a value higher than the bar you selected (for "Orders$").  Basically it will break the bar into a stacked bar showing these two values.  However, if the bar is less than the one you selected, it will show the value of that bar (not the one you selected) for "Orders" and will show 0 for "Orders$).  

The last calculation will simply label any values above the selected bar.  

Now on the chart, replace Sum of Sales on Columns with Break Values.  Put Table Name onto the Color card to allow us to break that bar into the different colors.  Place Break Values Label onto the Label card.  And place Sum of Sales onto the tooltip.  (This is only needed here so that we can use it later to control the parameter.  We must have it on our view to control the parameter; I've actually turned tooltips off).  

Now, we need to add a reference line.  Drag a reference line onto the Table and set it to be equal to the Sales Parameter (the sum of sales for the selected bar).  Change the formatting of the line however you line.



Lastly, create a parameter action as follows:



Now, when you hover over any bar, it will show you the difference of that bar to all other bars by highlighting the difference using color and with an actual value.

15. Map Paths with "Make Line"



This example allows you to hover over a city to connect paths with other cities on the map.

To build this, follow the exact instructions on Jeff Shaffer's blog post about mapping paths on maps in 2019.2 (only the Cincinnati flight data example).  

How easy was that, huh?  What a cool new feature.  

We now need to set up some parameters and use them in the viz.  Create two parameters, one called Origin Latitude and one called Origin Longitude.  Both should be float data types and allow all values.

In his blog post, Jeff had you create the following calculation:


Flight Path:
MAKELINE(
   MAKEPOINT([CVG Latitude],[CVGLongitude]),
   MAKEPOINT([Destination Latitude],[Destination Longitude]))

We are going to replace the CVG Latitude and Longitude calculations with our parameters:  


Flight Path:
MAKELINE(
   MAKEPOINT([Origin Latitude],[Origin Longitude]),
   MAKEPOINT([Destination Latitude],[Destination Longitude]))
   
Now we will set up two parameter actions to feed the selected city's latitude and longitude into the parameters and therefore into the flight path calculation to draw the lines.  Let first put it on a dashboard then create these parameter actions (one for lat and one for long) as follows:




Now when you hover over any city, it will connect paths using make line from that city to all other cities on the map.

As a side note, this is not the proper data to utilize for this use case as it shows flights from Cincinnati to other cities.  It does not necessarily reflect flights from Dallas to other cities, or Los Angeles to other cities and therefore it makes little sense to hover over other cities to draw the lines.  The concept, however, is what I am focusing on.    

A Note on Swapping Data Sources

One option that I do not show in my workbook or this blog post is swapping data sources.  Since you can feed a parameter into custom SQL, you can control the data source.  As an example, many companies have SQL tables that are simply snapshots of each month; this means there may be hundreds of tables.  You can allow your user to dynamically connect to a different table by feeding a parameter into your custom SQL.  So, parameter actions will allow you to do so at the click of a button.  (We are actually doing something similar at my office with the parameter action extension currently available on Tableau Extension Gallery).

Wrap-Up

These are just a few ideas of things that you can easily do with parameter actions...some valuable and some not so valuable.  As mentioned, much of this has already been done with set actions, but for me, parameter actions are just a lot more logical.  In addition, values do not necessarily have to be in your data like with sets and actions can be applied across multiple data sets, which is where I believe the major advantages will lie.  

Anyway, I hope you enjoyed the blog post.  Please remember that I plan to continue to update this Parameter Action blog post and my Parameter Action workbook regularly.  Please check back for updates.

As always, if you ever have any questions, feel free to contact me at any time.  


Kevin Flerlage, May 22, 2019 | Twitter | LinkedIn | Tableau Public











No comments

Powered by Blogger.