Data Science Toolbox: How to use Julia with Tableau

R allows Tableau to execute Julia code on the fly
R allows Tableau to execute Julia code on the fly

Michael, a data scientist, who is working for a German railway and logistics company, recently told me during an FATUG Meetup that he loves Tableau’s R and Pyhton integration. As he continued, he raised the raised the question for using functions they have written in Julia. Julia, a high-level dynamic programming language for high-performance numerical analysis, is an integral part of newly developed data strategy in the Michael’s organization.

Tableau, however, does not come with native support for Julia. I didn’t want to keep Michael’s team down and was looking for an alternative way to integrate Julia with Tableau.

This solution is working flawless in a production environment since several months. In this tutorial I’m going to walk you through the installation and connecting Tableau with R and Julia. I will also give you an example of calling a Julia statement from Tableau to calculate the sphere volume.

1. Install Julia and add PATH variable

You can download Julia from julialang.org. Add Julia’s installation path to the PATH environment variable.

2. Install R, XRJulia and RServe

You can download base R from r-project.org. Next, invoke R from the terminal to install the XRJulia and the RServe packages:

> install.packages("XRJulia")
> install.packages("Rserve")

XRJulia provides an interface from R to Julia. RServe is a TCP/IP server which allows Tableau to use facilities of R.

3. Load libraries and start RServe

After packages are successfully installed, we load them and run RServe:

> library(XRJulia)
> library(Rserve)
> Rserve()

Make sure to repeat this step everytime you restart your R session.

4. Connecting Tableau to RServe

Now let’s open the Help menu in Tableau Desktop and choose Settings and Performance >Manage External Service connection to open the External Service Connection dialog box:

TC17 External Service Connection

Enter a server name using a domain or an IP address and specify a port. Port 6311 is the default port used by Rserve. Take a look on my R tutorial to learn more about Tableau’s R integration.

5. Adding Julia code to a Calculated Field

You can invoke Calculated Field functions called SCRIPT_STR, SCRIPT_REAL, SCRIPT_BOOL, and SCRIPT_INT to embed your Julia code in Tableau, such as this simple snippet that calculates sphere volume:

6. Use Calculated Field in Tableau

You can now use your Julia calculation as an alternate Calculated Field in your Tableau worksheet:

Using Julia within calculations in Tableau (click to enlarge)
Using Julia calculations within Tableau (click to enlarge)

Feel free to download the Tableau Packaged Workbook (twbx) here.

Further reading: Mastering Julia

Tableau Conference TC17 Sneak Peek: Integrating Julia for Advanced Analytics

Using Julia within calculations in Tableau (click to enlarge)
Using Julia calculations within Tableau (click to enlarge)

We have already seen some love from Tableau for R and Python, boosting Tableau’s Advanced Analytics capabilities.

So what is the next big thing for our Data Science Rockstars? Julia!

Who is Julia?

JuliaJulia logo is a high-level dynamic programming language introduced in 2012. Designed to address the needs of high-performance numerical analysis its syntax is very similar to MATLAB. If you are used to MATLAB, you will be very quick to get on track with Julia.

Compared to R and Python, Julia is significantly faster (close to C and FORTRAN, see benchmark). Based on Tableau’s R integration, Julia is a fantastic addition to Tableau’s Advanced Analytics stack and to your data science toolbox.

Where can I learn more?

Do you want to learn more about Advanced Analytics and how to leverage Tableau with R, Python and Julia? Meet me at the 2017 Tableau Conferences in London, Berlin or Las Vegas and join my Advanced Analytics sessions:

Will there be an online tutorial?

Yes, of course! I published tutorials for R and Python on this blog. And I will also publish a Julia tutorial soon. Feel free to follow me on Twitter @xlth, and leave me your feedback/suggestions in the comment section below.

Further reading: Mastering Julia

A German translation of this post is published on the official Tableau blog: Tableau Conference On Tour Sneak Peek: Julia-Integration für Advanced Analytics

[Update 11 Oct 2017]: The Julia+Tableau tutorial blog post is now published.

Enabling Multi-Language Sentiment Analysis

Have you seen how easy it is to integrate sentiment analysis in your Tableau dashboard – if your text is in English?

Until now the sentiment package for R only worked with English text. Today, I released version 1.0 of the sentiment package that features multi-language support. In order to perform sentiment analysis with German text, just add the parameter language="german" as shown in this example:

German sentiment analysis

The new code allows you to add any language. So far, I started to prepare German sentiment files. French and Spanish are coming…

R You Ready For Advanced Analytics at #data16

Tableau Conference: "What is Advanced Analytics?"
Tableau Conference: “What is Advanced Analytics?”

The main goal of Advanced Analytics is to help organizations make smarter decisions for better business outcomes.

Only a few years ago, Advanced Analytics was based almost entirely on a complex tool chain and plenty of scripting in Gnuplot, Python and R. Today, Tableau enables us to analyze our data at the speed of thought, to connect to our data sources in seconds, to add dimensions and measures on the canvas by dragging and dropping, and to get insights faster than ever before.

However, R still comes in very handy when we want to enrich Tableau’s Visual Analytics approach with advanced features that enables us to ask questions along the entire Analytics stack:

  1. Descriptive Analytics describes what happened, characterized by traditional business intelligence (BI). E.g. visualizations and dashboards to show profit per store, per product segment, or per region.

  2. Diagnostic Analytics, which is also known as Business Analytics, looks into why something is happening, and is characterized by reports to further “slice and dice” and drill-down data. It answers the questions raised by Descriptive Analytics, such as why did sales go down in a particular region.

  3. Predictive analytics determines what might happen in future (“What might happen?”), and needs larger domain expertise and tool set (i.e. Tableau + R). E.g. regression analysis, and forecasting which product segments are likely to perform better in next quarter.

  4. Prescriptive Analytics identifies the actions required in order to influence particular outcome (“What should I do?”). E.g. portfolio optimization, and recommendation engines to answer which customer segment shall be targeted next quarter to improve profitability.

  5. Semantic Analytics examines data or content to identify the meaning (“What does it mean?”), and suggests what you are looking for and provides a richer response. E.g. sentiment analysis and Latent Semantic Indexing to understand social media streams.

Do you want to learn more about Advanced Analytics and how to leverage Tableau with R? Meet me at the Tableau Conference in Munich (5-7 July) where I deliver the session “R You Ready For Advanced Analytics”.

"Analytics is essential for any competitive strategy"
“Analytics is essential for any competitive strategy” (further reading: data science + strategy)

How to implement Sentiment Analysis in Tableau using R?

Interactive sentiment analysis with Tableau 9.2
Interactive sentiment analysis with Tableau 9.2

In my previous post I highlighted Tableau’s text mining capabilities, resulting in fancy visuals such as word clouds:

Today I’d like to follow up on this and show how to implement sentiment analysis in Tableau using Tableau’s R integration. Some of the many uses of social media analytics is sentiment analysis where we evaluate whether posts on a specific issue are positive, neutral, or negative (polarity), and which emotion in predominant.

What do customers like or dislike about your products? How do people perceive your brand compared to last year?

In order to answer such questions in Tableau, we need to install an R package that is capable of performing the sentiment analysis. In the following example we use an extended version of the sentiment package, which was initiated by Timothy P. Jurka.

The sentiment package requires the tm and Rstem packages, so make sure that they are installed properly. Execute these commands in your R console to install sentiment from GitHub (see alternative way to install at the end of this blog post):

The sentiment package offers two functions, which can be easily called from calculated fields in Tableau:

Screenshot 2016-01-31 15.25.24 crop

The function get_polarity returns “positive”, “neutral”, or “negative”:

The function get_emotion returns “anger”, “disgust”, “fear”, “joy”, “sadness”, “surprise”, or “NA”:

The sentiment package follows a lexicon based approach and comes with two files emotions_english.csv.gz (source and structure) and subjectivity_english.csv.gz (source and structure). Both files contain word lists in English and are stored in the R package library under /sentiment/data directory.

If text is incorrectly classified, you could easily fix this issue by extending these two files. If your aim is to analyze text other than English, you need to create word lists for the target language. Kindly share them in the comments!

Feel free to download the Packaged Workbook (twbx) here.

[Update 11 Aug 2016]: If you are having trouble with install_github, try to install directly form this website: