Skip to main content

Creating a Dynamic one click PDF button in Tableau

Can I get that in a PDF view?  If you are a report developer, you have most likely heard this question before. In Tableau, you can choose to print any dashboard as a PDF from the toolbar in Tableau Server, but if your dashboard contains a lot of heavy color, you may want to create a separate layout for your printable PDF.  You could send your users to another dashboard with a separate view design, but what if you could do this, and then generate your PDF in one step?  This would allow your users to generate a PDF and separate view in one click.

In this exercise, we are going to create a Tableau button that automatically generates a PDF with an updated look specifically for PDF views only on click.

First, we need to create a customized Tableau button. This process is very similar to the first article in this series, "Creating a custom Tableau button" except instead of using a Tableau Shape for our button, we will use an image.



1. Navigate to your “My Tableau Repository” on your computer.  This folder is typically located under the following hierarchy:
Computer Name >




2. Create a new folder under “Shapes” named “Custom”.


3. Find an image that you would like to use on the web or on your local drive for your print icon.  The below image can be used.  To use the image below, right click the image and choose, “save picture as” and choose a filename for the image.



4. Save the image to the new “Custom” folder you created.


5.  Create a new worksheet in Tableau.  The button will reside on a worksheet by itself.


6. Create a calculated field. Give the calculated field a title.  Add the text that you'd like the button to contain within quotes.  For the example below, we will use, “Print to PDF” and select “OK”.
7. Select the dropdown under “Marks” and choose “Shape”.


8. Click on the “Shape” button and choose, “More Shapes”


9. Select “Custom”



10. Choose the custom shape you created.
8. Make adjustments to the spacing between the text and the button to pull the button closer to the text.

9. Right click the button text and select "format". Then select the borders icon and click on "Rows".
 

10.  Under Row Divider and Column Divider set pane to "None".

11. Click on the tooltip button and change the tooltip text to what the button will say when the user hovers over the button.


12. Drag the newly created button to your first dashboard.

The button is now built!  Now let’s build a Print view and apply a Dashboard Action to the button.

13. Create a view of your report with limited background colors.  See the example below:

Web Dashboard view with color (original report view - non print view):



Similar Dashboard for PDF View:


14.  Any Dashboard that is deployed to Tableau Server can be automatically converted to a PDF by using the “Share” button, copying the URL for “link” and removing everything in the URL link starting with the “?” and replacing it with “.pdf” at the end of the URL.


*Note - you can also use a .png extension if showing an image of your dashboard is desired instead.


15. Copy the "link" from step 14 (and ensure ".pdf" is added as step 14 describes).


16. Test the new link you just created by pasting it into your browser window.  Notice that the link is static, and shows the report with the filters the report was uploaded with.


17. Ensure you have that link copied. (We will paste the link in step 24.)


18. Go to Dashboards > Actions


19. Click “Add Action”


20. Name the Action “Go To PDF”.



21. Select your source dashboard (the view that is not the PDF View)


22. Place a checkmark next to the print button you created.


23. Select “Select” for “Run action on:”

24. When using URLs, you may need to experiment with these settings.

More info:
-If you have filters that have multi select, ensure you have allow multiple values checked. -If you have fields that have commas in them, consider using a different delimiter value
-If your fields have special characters, for example a "&" sign, you would want to check "URL Encode Data Values" because if not, the URL string may be translated incorrectly once you pass it to your browser.



25. To make the PDF dynamic, add a question mark after “.pdf” and add in a filter name that was used in the report.  In this example, there is a filter named “PCT_GROUP”.  Select the arrow next to the URL, and choose to to pass the Filter value or the field name to the PDF view.

26. To pass in additional fields after the initial field, use a “&” and be sure to include the filter name, the “=” sign and then click the arrow again and choose to pass the filter value or the detail value from the first dashboard.


27.  The link can be tested by choosing “test link”.


28. If the link doesn’t work on the first test, be sure that you are including all filters that are located on the PDF version of the report and continue to test until you get a working PDF.


29.  Now the PDF launches its own customized view on a single click.  The PDF is quick and easy and more intuitive for report users.

Comments

Popular posts from this blog

Transfer Apple Watch or Apple Health data to Excel or Sheets

Have you ever attempted to get the data from your Apple Watch or Apple Health app into a format you can share with others?  Maybe you'd like to share this information with a doctor, or maybe you'd simply like to analyze the data yourself in Excel.  There are XML converters out there, but once you get the data from these converters into excel using this technique, the data can look quite ambiguous. Luckily, "There is an app for that."  It's called QS Access.  This solution is very quick and easy for exporting your data into a format you can use quickly. Unfortunately with this app, you won't be able to export every field from your apple watch, however you will be able to export fields such as: Active Calories Resting Calories Steps Distance Flights Climbed Heart Rate Blood Pressure Calories Weight BMI and more... So how do you get this app?  Simply go to the app store from your Apple iPhone and search for "QS Access".  Once you...

Creating an Action for a Tableau Button

In the previous exercise we created a customized Tableau button using Marks and Shapes . In this article, we will set up a Dashboard action that will allow you to click through to another Dashboard within your workbook.   1. Click on your first Dashboard and ensure that the item you want to create an action for is on your dashboard. 2. Go to Dashboard > Actions 3. Click on "Add Action" 4. For this example, we will choose "Filter" 5. For Source Sheets, make sure your first dashboard is selected.     (Use the image below to help you with Steps 5 - 12) 6. Under Source Sheets place a check mark on your button to have the action run when the button is selected. 7. Choose how you would like to initiate the action.  For this example, we will choose "Select". 8. For Target Sheets, make sure your destination dashboard is selected.  9. De-select all sheets under "Target Sheets". 10. Click on "Selected Fields...