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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
MattiaFratello
Super User
Super User

Predictions in Power BI

Hi community,

I'm working with monthly data spanning 25 months in this structure:

month | category1 | category2 | category3 | total_customers
 
My goal is to generate predictions for 3 future months based on historical trends.
Even better if I can appen them to the existing table.
 
What's the best approach?
1 ACCEPTED SOLUTION
Natarajan_M
Solution Sage
Solution Sage

Hi   @MattiaFratello  , You can make use of the line chart and the default forecast options .

Data :  

Natarajan_M_6-1772489490789.png

 




Line chart : 

 

Natarajan_M_7-1772489514058.png

 



Setting : 
if you need to build a linear regression you can build it using the dax but check before hand whether the data fits the line .

Natarajan_M_3-1772489162329.png


Linear Forecast =

VAR _HistoricalData = FILTER( ALL('CustomerData'), NOT ISBLANK('CustomerData'[Total_Customers]) )

VAR _N = COUNTROWS(_HistoricalData)

VAR _SumX = SUMX(_HistoricalData, INT('CustomerData'[Month]))

VAR _SumY = SUMX(_HistoricalData, 'CustomerData'[Total_Customers])

VAR _SumXY = SUMX(_HistoricalData, INT('CustomerData'[Month]) * 'CustomerData'[Total_Customers])

VAR _SumX2 = SUMX(_HistoricalData, INT('CustomerData'[Month])^2)

// m and b

VAR _Slope = DIVIDE( (_N * _SumXY) - (_SumX * _SumY), (_N * _SumX2) - (_SumX * _SumX) )

VAR _Intercept = DIVIDE( _SumY - (_Slope * _SumX), _N )

// Forecast period

VAR _CurrentDate = INT(MAX('FutureCalendar'[Date]))

// y = mx + b

VAR _Prediction = (_Slope * _CurrentDate) + _Intercept

RETURN

_Prediction

 

 

Thanks 

 

 

If this response was helpful in any way, I’d gladly accept a kudo.
Please mark it as the correct solution. It helps other community members find their way faster

View solution in original post

1 REPLY 1
Natarajan_M
Solution Sage
Solution Sage

Hi   @MattiaFratello  , You can make use of the line chart and the default forecast options .

Data :  

Natarajan_M_6-1772489490789.png

 




Line chart : 

 

Natarajan_M_7-1772489514058.png

 



Setting : 
if you need to build a linear regression you can build it using the dax but check before hand whether the data fits the line .

Natarajan_M_3-1772489162329.png


Linear Forecast =

VAR _HistoricalData = FILTER( ALL('CustomerData'), NOT ISBLANK('CustomerData'[Total_Customers]) )

VAR _N = COUNTROWS(_HistoricalData)

VAR _SumX = SUMX(_HistoricalData, INT('CustomerData'[Month]))

VAR _SumY = SUMX(_HistoricalData, 'CustomerData'[Total_Customers])

VAR _SumXY = SUMX(_HistoricalData, INT('CustomerData'[Month]) * 'CustomerData'[Total_Customers])

VAR _SumX2 = SUMX(_HistoricalData, INT('CustomerData'[Month])^2)

// m and b

VAR _Slope = DIVIDE( (_N * _SumXY) - (_SumX * _SumY), (_N * _SumX2) - (_SumX * _SumX) )

VAR _Intercept = DIVIDE( _SumY - (_Slope * _SumX), _N )

// Forecast period

VAR _CurrentDate = INT(MAX('FutureCalendar'[Date]))

// y = mx + b

VAR _Prediction = (_Slope * _CurrentDate) + _Intercept

RETURN

_Prediction

 

 

Thanks 

 

 

If this response was helpful in any way, I’d gladly accept a kudo.
Please mark it as the correct solution. It helps other community members find their way faster

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.

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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.