In this blog post, we will go through how to turn your viz into a poll! Yes, this means you can use Tableau Public as a data collection source. To do so, we will harness the amazing power of Tableau Public by using a viz for the user input. Then using Dashboard actions, we will send the responses from the user to a Google Doc for collection of the information. Please begin by taking our poll about the Tableau Public blog!
For our purposes, we will be walking through how to create the poll shown at the beginning of this blog post.
Step 1: Create a viz
Once you have created a viz in Tableau with some variable parameters, you must then determine which fields you would like to record in your poll. For this particular poll, we will be polling the preferences for: contests, how-to/tutorials, resources, interviews/spot light, round-up and news.
Whether you already have some data regarding your poll or not, you must start out by giving Tableau something to work with.
- For this particular viz, I do not have any data on the preferences for our readers so I must go into Excel and created a new spreadsheet. The given spreadsheet below can be easily created and will give Tableau a starting point for creation of the poll. Now, open a new Tableau Workbook and connect to this spreadsheet.
- On the other hand, if you do have some data regarding your poll, you will first need to connect to your data in Tableau. We need to create a new dimension that will correspond to the submit feature of the poll. Right click on the sidebar and select "Create Calculated Field...".
In the "Formula:" section, it is very important to place "quotes" around the entire word Submit. Tableau will interpret this as a string which will prove very useful in later steps of the creation of our poll.
From our poll, we will want readers to have the ability to change the values for each category according to their preferences. To do so, we will utilize parameters in the dashboard. We must first create the parameters—one for each of the six categories in our poll. To create the parameters, right click anywhere on the left side bar and select “Create Parameter…”.
A new window will appear in order to specify the details of the parameter. Suppose we first want to create the parameter for the category: Contests. At this point, name the parameter as you would like it displayed on your poll. Then, under “Allowable values:”, select Range and specify an allowable range of values. Since we want to give our readers full power over their preferences, we set the allowable range from 0 to 100.
Repeat this process for each of the parameters in your poll. By the nature of the poll we are creating, we do not want the preferences to add up to more than 100%.... Duh. To ensure this, right click on the left side bar and select “Create Calculated Field…”.
We will be creating six calculated fields—one for each of the parameters.
For this calculated field (Contests), we have the proportion the Contests parameter ``takes up'' of the sum of all parameters. The rest of the calculated fields will have a different numerator of [Parameters].[fill in corresponding parameter]. The denominator for each of the calculated fields will be identical:
Now we have all the necessary “ingredients” to create our poll! In blank sheet, drag Measure Values to columns and Measure Names to Rows. Now, it doesn't make much sense to have “Number of Records” on our poll, so we simply remove it from our Measure Values card.
To change the values of each parameter for the poll, right click on each parameter and select “Show Parameter Control”.
With the parameter controls, you can change the values to reflect your preferences. Notice that the numbers on the display window of the parameter controls do not add up to 100… in fact, they can easily exceed 100. Don’t fret! By design of the calculated fields, the proportion of each of the categories will add up to 1.0—which corresponds to 100%.
Finally, the readout on the parameter slider bar is not very visually appealing. In fact, any meaning we gain from the readouts, we can also gain from viewing the bars on the viz. So we do away with these readouts by selecting the drop down arrow on each of the parameter controls, go to “Customize” and deselect “Show Readout”.
Our sheet for our poll is now complete! Now the readers will have the ability to alter their preferences. The next step is to create the “Submit” button. The submit button will actually be a sheet in our workbook that will link to our Google Doc.
First, drag the Submit dimension to the Filters card.
Next, change the automatic “Abc” mark type from the automatic text to shape. This will display a shape instead of displaying the text of the field.
If you would like a shape other than a circle for the Submit button, simply click on shape button and choose your favorite design.
We must now "attach" the values we want in our poll to the submit button (the sheet). To do so, drag each of the calculated fields and drop on the Detail button of the marks card.
Now that all of the necessary information is attached to the submit button, we must change each of the details from a sum to an attribute - exactly as we did above on the poll sheet.
We are getting close to having our poll completed! Our next step is to create a dashboard that contains our poll sheet and submit button sheet.
Step 2: Create a Google Form
If you do not already have a Google Drive, now is the time to create one! Once you have an account, click on the "CREATE" button on the left side of the screen and select Form.
Once your form is created, choose a title and theme and select OK. Now is the time to specify all of the areas you would like polled. Each of our poll values –Contests, How-to/Tutorials, Interviews/Spotlight, News, Resources and Round-up—will be a question on the Google form. To add each question, select “Add Item”.
Once each question has been added, go to response tab at the top of the window and select “Get pre-filled URL”. This will help us get the link from the Google form to our Tableau viz poll.
Re-type the field name into the box below it and select “Submit” at the bottom of the window. It is very important at this step to make sure you enter in the exact name of the given calculated field from Tableau. For example, I named the calculated field Contests—with a capital C.
After selecting “Submit”, a new window will appear with “Share this link to pre-fill the responses”.
The given link is:
Now, search for viewform? and replace with formResponse?ifq& in the URL. At this step, you will also want to add &submit=Submit to the end of the URL. The resulting URL will look like:
Notice that each of the words we filled in below the questions appear in the URL. To link these to Tableau, we must add ATTR( ) and carrots around each of the calculated field names. Notice these changes in red in the image below. Now the URL is:
Step 3: Link your viz and Google Doc
Now that our viz and Google Doc are both set up, we are very close to being done! To connect these two pieces, we use a Dashboard Action.
Once in the Dashboard Actions window, select Add Action and then URL. At this point, we need to change a few items on this window:
- Deselect “Poll”. At this step, the only sheet we want checked is the one that contains the Submit button.
- Run action on “Select” as opposed to “Menu”.
- Copy-and-paste your link from the end of Step 2:Create a Google Doc into the URL box.
- Click “URL Encode Data Values”.
- Select OK.
The resulting window should look like:
Your poll should be fully functioning now and you may add any additional design elements to customize your poll. Because the connection is highly case sensitive, it is important to test before publishing. To test the connection from your viz to the Google Doc, simply hit "Submit" on your Dashboard.
If you receive an error message, double check that your linking URL matches the format given above. On the other hand, if you are directed to a window that reads "Tableau Public Poll - Your response has been recorded", then your poll connection is active and ready to be published! To check the responses, go to your Google Drive and select the spreadsheet.
See the responses come in! Each response will be placed into a row of your Google Doc.
Happy vizzing and polling!