Wednesday, September 21, 2016

Tableau 10 – Custom Territories

Tableau 10 has come up with some new features like define custom territories, cross database joins, connection to Google spread sheets, cross data source filters, new options in Bar charts etc..

Here, I will explain you how to create custom territories in Tableau 10, and how it is different compared to Tableau 9.

Here, I am using "Sample – Superstore (Sample - Superstore.xls)" as data source.

Just have a look at below table for "State wise Sales" information.
State wise Sales (Excel Pivot Table)
State wise Sales (Tableau Map View )


Create Custom Territories using Groups in Tableau 10

Step 1. Connect to "Sample Superstore Excel data source", and create "State wise Sales" filled map view.
   image 1 : State – Color, Text & Detail; SUM(Sales) - Text
Step 2. Create a group by selecting multiple states and click on "Grouping icon" in the above map view as shown in below snapshot.
   image 2
Then, view will become like this
   image 3 : A new dimension State (group) placed in "Dimensions" section and on Color legend;
Step 3. Now, remove 'State' field from Label & Detail;   Drag and drop 'State (group)' on to Label & Detail;
             See the output below. Now you can see all the 4 states with a combined border.

   image 4

If you perform the above steps in Tableau Desktop 9, below is the output.
   image 5 : here those 4 states not covered with border.

Happy coding!!!

Wednesday, September 14, 2016

Generate PDF document of a Tableau view and send it as an email attachment

In this article I will explain how to generate PDF file/document of a Tableau view, send this document as an attachment in email and how to automate this procedure.

We can achieve this task using Tableau Server command line tool (tabcmd) and third party email sending utilities.

Generate pdf file of Tableau View
  • Go to Tableau Server machine, open Command Prompt with administrative rights
  • On Command Prompt, navigate to Tableau Server bin directory by typing the below command
  cd C:\Program Files\Tableau\Tableau Server\<version>\bin
                   (or)
cd C:\ Program Files (x86)\Tableau\Tableau Server\<version>\bin
  • Login to Tableau Server using below command
tabcmd login -s http ://<host>:<port> -u <username> -p <password>

ex: tabcmd login –s http://localhst:8000 –u <usrname> -p <pwd>

You can see some status message after running the above command.
  • Now, type the below command to generate pdf file of Tableau view
     tabcmd get "<url-of-view>" -f "<filename>.pdf"

ex: tabcmd get "/views/Dashboard-SalesProfits/Dashboard2" -f "C:\tmp_Folder\dashboard22.pdf"


      pdf file will be generated and saved in C:\tmp_Folder (create this folder before executing the             above command).


Email the generated pdf file as an attachment

First of all, download and install “febootimail” command line email sending utility from http://www.febooti.com/ website.
  • On Command Prompt, navigate to “feebootimail” installation path
cd C:\Program Files (x86)\Febooti Command line email

febootimail -SMTP <your-mail-smtp> -PORT <port-number> -TO "<email-1; email-2>" -FROM <email-from-id> -SUBJECT "email subject line" -ATTACH "<path-of-generated-pdf-file>" -BODY "email message"

ex: febootimail -SMTP mail.infinysis.com -PORT 25 -TO "naga.allaboutbi@gmail.com" -FROM naga.k@infinysis.com -SUBJECT "Tableau View - PDF format " -HTML -TEXT "Hi, <br/> Please find the attached file for Tableau view in pdf format. <br /><br /> http://localhost:8000/ " -Attach "c:\tmp_Folder\dashboard22.pdf" -AUTH LOGIN -USER naga.k@infinysis.com -PASS *******

      Here is the snapshot of the email message
    

Additionally, you can put the entire script in a BATCH file and schedule it using windows task scheduler.


Find the complete script below.


Happy coding!!!