• Franco Arda

How to add a Multiple Linear Regression prediction from R in Tableau?

While we can do a Linear Regression directly in Tableau, we can't do a Multiple Linear Regression without using R or Python. In this blog post, I present a "new" approach: instead of using Rserve to connect R directly to Tableau, we create first a MLR model in R and use the prediction functions directly in Tableau's Calculated Field.

The advantage? We don't need to set up Rserve. All the code is organically written in R. Let's code it. In this example, a company runs ads on Google, LinkedIn, and Facebook. Based on ad spending, they get different sales volumes. I wrote a simple MLR model in R and extract the intercept and coefficients to add them in Tableau's Calculated Field:

The variables for Google_Ads, LinkedIn_Ads, and Facebook_Ads are parameterized in Tableau. By doing so, we empower the business user to change them and get an updated "predict sales from ads" number. In other words, change the parameters and the predicted sales from ads changes.

A technical advantage of Tableau's parameters is the min and max values. By setting them in advance, the user cannot extrapolate to values we have not covered.

This approach can be used for literally any model with MLR. And, with the power of Tableau, business users are empowered to make data-driven decisions - even on a mobile device.

Don't ask me why this approach is not well-known. I don't know. But I believe it shows that with a bit of creativity, we can give business users powerful tools in their hands (literally if they hold a smartphone). Franco


Franco Arda, Frankfurt am Main (Germany)                                                                                                                 franco.arda@hotmail.com