1 Reply Latest reply on Sep 1, 2016 9:45 AM by Santiago Sanchez

    Forecasting in Tableau using R Code

    pavan kumar

      I am working on Insurance POC,

      I need to show the future trend of premium.

      i am unable to complete this.

      Can anyone help me?

       

       

      Here is R Code.

       

      SCRIPT_REAL("library(forecast);

      time <- ts(.arg1,start=c(2014,1), frequency=12);

      fcast <- forecast(time, h=.arg2[1]);

      n<-length(.arg1);

      append(.arg1[(.arg2[1]+1):n],fcast$mean, after = n-.arg2[1])",

      AVG([Premium]),[Months to Forecast])

       

      This is the error message i am getting.

       

       

       

      Thanks and Regards

      Pavan Kumar

        • 1. Re: Forecasting in Tableau using R Code
          Santiago Sanchez

          If you change the value of your parameter [Months to Forecast] to 2 or less, you'll get a result back. Not an R expert, but that seems to be happening because you only have 3 months in your data set. For instance, if you try this calculation, it works:

           

          SCRIPT_REAL("library(forecast);

          time <- ts(.arg1, start=c(2014,1), frequency=12);

          fcast <- forecast(time, h=.arg2[1]);

          n<-length(.arg1);

          append(.arg1[(.arg2[1]+1):n],fcast$mean, after = n-.arg2[1])",

          AVG([Premium]),2)

           

          The attached workbook has an example with SuperStore in Tableau 10.

          1 of 1 people found this helpful