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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Anonymous
Not applicable

Loop in R Script

Hi,

 

I need help with a code for R script. I need to use Arima. 

 

I have 3 years of sales data on month level, for X number of store and Y number of categories. 

 

I need to create a forecast per store, per category for the next 3 months (on month level), and I need the data to be written to a table so that I can make measures using this data. 

 

I can get it to run for one store, one category, but I need R to somehow do a loop, so that I get the forecast for each store and each category. So, when finished with the first category for Store 1, I need it to do the same for category 2 - Store 1. When it is done with all categories for Store 1, it needs to move on to store 2 and do the same for all categories.

 

Example of data:

 

Month

Store Name

Category

01.2018

Store 1

Category 1

01-2017

Store 1

Category 1

01-2016

Store 1

Category 1

01.2018

Store 1

Category 2

01-2017

Store 1

Category 2

01-2016

Store 1

Category 2

01.2018

Store 2

Category 1

01-2017

Store 2

Category 1

01-2016

Store 2

Category 1

 

 Thank you in Advance. 

 

/Kristina 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi,

 

Sorry I forgot to say that it is R Script in Power BI I want to use, but yes maybe I can try and ask there.

 

Thank you, 

View solution in original post

3 REPLIES 3
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

Due to this community is for Power BI, I suggest you recreate this topic in R community:

https://community.rstudio.com/

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi,

 

Sorry I forgot to say that it is R Script in Power BI I want to use, but yes maybe I can try and ask there.

 

Thank you, 

Hi @Anonymous,

Could you please mark one reply as Answered to close this topic?

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.