top of page

Tableau実践問題集 #TableauChallenge を作りました。

Tableau Dashboard Training 1-7: Time Series Analysis with R in Tableau

In this post, I'd like to talk about

1. How to use R in Tableau

2. Time-series decomposition visualization in Tableau

3. Forecast with ARIMA model

We are back to data visualization finally. As far as I know there is not much information about R codes in Tableau, especially time-series analysis. I hope my blog helps you learn this combination.


First of all, we have to connect Tableau with R. References are here (first 2 are written in Japanese).

  1. You have to install a package "Rserve" so run the code install.packages() first. Then, just do library(Rserve) and Rserve().

  2. Go to Help -> Setting and Performance -> Manage External Server Connection and set it.

  3. Make sure you choose "localhost" and test it. That's all.


Then, let's see the decomposed data first. For time-series decomposition, please see the previous post. For example, code for seasonal trend is here (This is for Tableau, not for R).

In this code, I made a parameter "Frequency" before. It is almost the same to create a "parameter" as creating calculation field.

In addition, I made Forecast Interval parameter too. This is the same as this parameter.

Then, let's see the decomposition in Tableau.

This is the result of decomposition based by month. So far I am not able to talk about this result: what each result shows. After I finish this series, I will study this analysis with textbooks and I would like to share some knowledge with you.


As for the forecast, we need a bit tricky code. for the detail, please see the references above.

To begin with, we need another date columns.

Here is another parameter that is "Shifting".

And forecast code with ARIMA model is here ( I don't know why but xts object didn't work, so I changed time-series codes from xts to ts).

Then, this is the result. The no.1 reason why I have been wanted to forecast in Tableau is because, we don't have to do segmentation in codes like R. Like this figure, we can forecast sales with certain segments such as customer type and product category.

THIS IS AWESOME. I'm really excited.

Code for "Product vs Actual" is here.


Through 1-1 to here, I hope you get some knowledge of how to create interactive and actionable dashboard. I hope you had a fun with this post. See you.

bottom of page