Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

When using the script editor to plot a time series, my data is reversed

Hello,

So I am new to power bi and R but I am using the r visual in power bi to plot a time series from my data. My data is revenue per quarter per year per region since 1999. Now, I didn't have a problem when I first made a time series object but when I graphed the times series I realized that the graph seemed to be reversed. Here is a pic of the ts graph

So my data should actually be increasing not decreasing at this shows, and the values at either end are correct but are with the incorrect year which is why the data is somehow reversed.  Here is my code:

                    Column1Ts<-ts(dataset[,1],start=c(min(dataset[,2]),1),frequency=length(unique(dataset[,3])),end=c              (max         (dataset[,2]),length(unique(dataset[,3]))))                
                    plot.ts(Column1Ts)

dataset[,1] corresponds to my revenue column in the data frame, dataset[,2] is the Years, and dataset[,3] are the quarters.  I am thinking I am missing something that is right in front of my eyes, and again my data should be increasing not decreasing like in the graph above.  Any help is greatly appreciated, thank you.

2 Replies

  • v-piga-msft's avatar
    v-piga-msft
    Resident Rockstar

    Hi Anonymous ,

    To have a test, could you share the data sample which could reproduce your scenario?

    Please upload with table format and do mask the sensitive data before uploading.

    Best Regards,

    Cherry

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      I unfortunately can't give my specific data that created this plot.  However, when I first tried to fit an arima model to this data I got an error saying that it was multivariate data and arima can only handle univariate but after I placed my data in the ts function then it worked with arima.  So, I tried some other random datasets that were similar to this one, basically just looking at revenue per quarter per year per region per customer. Each that I tried had the same type of reversed data on the graph, so this led me to think that maybe this was due to having multiple data entries per quarter per year.  Do you suppose that this could be the case? Should I try to use maybe an xreg term in my ts() function? If so, what should the xreg term be?

      Thank you for your responses, and again I apologize that I can't provide my specific data.