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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Fighting21
Frequent Visitor

Using linest function example

I am learning how to use the linest function. The graph in the photo below is a linest graph I created, but the values ​​seem to be coming out strangely. Can you make one using the linest function or linestx function using the example file below?

https://drive.google.com/file/d/17Ar2TXllzxBGsWMKDi0XRkl_2tDgBIxP/view 

example.pngnotcorrect.png

 

1 ACCEPTED SOLUTION

Want to predict sales for the below five estimated year:

shafiz_p_0-1730547559118.png


Try code as below:

PredictedValues = 
VAR Intercept = MAX(PredictedValue[Intercept])
VAR Slope = MAX(PredictedValue[Slope1])
VAR Year = SELECTEDVALUE('Estimated Year'[Est Year])

RETURN
Slope * Year + Intercept

 

Now you can develop visual you want, say line chart:

shafiz_p_1-1730547807596.png

 

 

Hope this helps!!

If this solved your problem, please accept it as a solution and a kudos!!

 

Best Regards,
Shahariar Hafiz

View solution in original post

3 REPLIES 3
shafiz_p
Super User
Super User

Hi @Fighting21 , Linest or Linestx function is a Least Squares method which basically use to predict what could be the future data. For example, if I have sales data of past year, what could be the sales value of the upcomming year based on the past data.

These function returns table of estimates, which you can use to predict future. For example:

lines = 
LINEST(
    'DataTable'[Value], 
    'DataTable'[Date]
)

This will return a table with many estimator as follows:

shafiz_p_0-1730532138006.png

You can use Slope and Intercept to establish equation as : Slope * [Value] + Intercept.

Hope this helps!!

If this solved your problem, please accept it as a solution and kudos!!

 

Best Regards,
Shahariar Hafiz

Thank you for your reply thank you very much, but could you know how to wirte [?Value?] in this example file? this is key of my question.

 

var _slope = SELECTCOLUMNS(ssd,[Slope1])
VAR _interc = SELECTCOLUMNS(ssd,[intercept])
RETURN
[?Value?]     *    _slope  +_interc

Want to predict sales for the below five estimated year:

shafiz_p_0-1730547559118.png


Try code as below:

PredictedValues = 
VAR Intercept = MAX(PredictedValue[Intercept])
VAR Slope = MAX(PredictedValue[Slope1])
VAR Year = SELECTEDVALUE('Estimated Year'[Est Year])

RETURN
Slope * Year + Intercept

 

Now you can develop visual you want, say line chart:

shafiz_p_1-1730547807596.png

 

 

Hope this helps!!

If this solved your problem, please accept it as a solution and a kudos!!

 

Best Regards,
Shahariar Hafiz

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.