Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
fave17
New Member

r script error power bi object not found

Hi, I have been trying to solve this problem on PowerBI for the past hours but nothing seems to work. Here is my script:

 

# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script:

# dataset <- data.frame(Year, Sales revenue (£m))
# dataset <- unique(dataset)

# Paste or type your script code here:

setwd("x")

# Assume the data starts from the first year available and increments yearly
sales_ts <- ts(dataset$`Sales revenuem)`, start = min(dataset$Year), frequency = 1)

install.packages(forecast)

# Fit an ARIMA model
library(forecast) # Ensure the forecast library is loaded
fit <- auto.arima(sales_ts)

# Forecast the next 5 years
future <- forecast(fit, h = 5)

# Plot the historical data and forecasts
plot(future)


2 REPLIES 2
lbendlin
Super User
Super User

Where are you plotting to?  Your code is missing the reference to the built-in plotting library.

I have modified my code to this:

 

# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script:

 

# dataset <- data.frame(Year, Sales revenue (£m))

# dataset <- unique(dataset)

 

# Paste or type your script code here:

 

# time series forecasting

 

dataset <- unique(dataset)

library(forecast)

 

# Assume the data starts from the first year available and increments yearly

sales_ts <- ts(dataset$`Sales revenue (£m)`, start = min(dataset$Year), frequency = 1)

 

# Fit an ARIMA model

fit <- auto.arima(sales_ts, seasonal = TRUE)  # If seasonality might be a factor

 

# Forecast the next 5 years

future <- forecast(fit, h = 5)

 

# Plot the historical data and forecasts

plot(future)


This the plot:

fave17_1-1714595008801.png

I'm not sure why there is a gap between the historical data and the forecast

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.