Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calendar fields and TimeSeries function in R

I'm doing a demo on R integration on Sense and I've come across a problem with ts( start=c()) function.

I can't get the start working in my dataset (I can drop the not wanted rows in load script), is there something I should take into consideration while generating the calendar for it to work with R timeseries functions?

So in short the problem is that I'd like the forecast function to start forecasting from a spesific year instead of from the first date.

Thx

here's the script for clarification:

R.ScriptEval('library(forecast);'&

    'data<-ts(na.omit(q$Variable1),frequency=12, start=c(1998,1));'&

    'fit<-auto.arima(data);'&

    'res<-forecast(fit, level=0.95, h=q$vForecastPeriods); '&

    'n <- length(q$Variable1); '&

    'fore <- append(q$Variable1[(q$vForecastPeriods - 1):n],res$mean,after= n - q$vForecastPeriods); '&

    'fore;',

    Sum(NoZerosco2) as Variable1,

    $(vForecastPeriods) as vForecastPeriods)

Labels (1)
3 Replies
Anonymous
Not applicable
Author

Hi Jokke,


You will need to create blank rows in Qlik Sense to fill with your forecast data.


Regards,

Bas.

Not applicable
Author

So you're suggesting that I do this in load script and dump the results in a new dimension? And then use that as a calculation in graph etc?

Anonymous
Not applicable
Author

You will need to generate rows in your data set with time dimension in the future but with empty data. When using the expression to do the calculation of your measure. The result of the expression will be used to create the chart.