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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
DataStraine
Advocate I
Advocate I

Linear Regression Not Working As Intended

Hello all. I'm hoping someone in the community could help me out. I am trying to create a basic linear regression prediction. I've followed the following tutorials, but neither of them worked properly.

 

Use Custom DAX to create a Linear Regression Trendline with a Dynamic Date Hierarchy in Power BI

* Simply Linear Regression YouTube 

 

When I follow the first tutorial, I end up just getting a straight line for my regression. When I followed the second tutorial and use the date table in order to see dates into the future, the regression line ends up tracking perfectly to the actual amount sold. Neither method, when it works, actually shows me what the data should be on a future date.

 

Please find below some sample data that mimics the data I'm working with. In addition to this data, I use a DAX-created Date Table to filter dates. I need to be able to use linear regression to predict the future values of each product on the quarter level. 

 

Edit: Please be aware that the data I am using is by day with many blanks, but to be able to post here I had to pair it down to the month level.

Edit 2: The dates into the future aren't in the same table as the sold info. 

 

DateProductSold
1/1/2020Product One14
2/1/2020Product One24
3/1/2020Product One10
4/1/2020Product One12
5/1/2020Product One15
6/1/2020Product One22
7/1/2020Product One3
8/1/2020Product One26
9/1/2020Product One22
10/1/2020Product One2
11/1/2020Product One17
12/1/2020Product One14
1/1/2021Product One28
2/1/2021Product One4
3/1/2021Product One1
4/1/2021Product One1
5/1/2021Product One13
6/1/2021Product One7
7/1/2021Product One5
8/1/2021Product One28
9/1/2021Product One15
10/1/2021Product One22
11/1/2021Product One5
12/1/2021Product One1
1/1/2022Product One10
2/1/2022Product One28
3/1/2022Product One12
4/1/2022Product One64
5/1/2022Product One29
6/1/2022Product One16
7/1/2022Product One17
8/1/2022Product One16
9/1/2022Product One16
10/1/2022Product One5
11/1/2022Product One27
12/1/2022Product One 
1/1/2023Product One 
2/1/2023Product One 
3/1/2023Product One 
4/1/2023Product One 
5/1/2023Product One 
6/1/2023Product One 
7/1/2023Product One 
8/1/2023Product One 
9/1/2023Product One 
10/1/2023Product One 
11/1/2023Product One 
12/1/2023Product One 
1/1/2024Product One 
2/1/2024Product One 
3/1/2024Product One 
4/1/2024Product One 
5/1/2024Product One 
6/1/2024Product One 
7/1/2024Product One 
8/1/2024Product One 
9/1/2024Product One 
10/1/2024Product One 
11/1/2024Product One 
12/1/2024Product One 
1/1/2021Product Two18
2/1/2021Product Two32
3/1/2021Product Two53
4/1/2021Product Two47
5/1/2021Product Two59
6/1/2021Product Two38
7/1/2021Product Two46
8/1/2021Product Two39
9/1/2021Product Two68
10/1/2021Product Two54
11/1/2021Product Two33
12/1/2021Product Two27
1/1/2022Product Two61
2/1/2022Product Two31
3/1/2022Product Two25
4/1/2022Product Two12
5/1/2022Product Two36
6/1/2022Product Two61
7/1/2022Product Two67
8/1/2022Product Two37
9/1/2022Product Two25
10/1/2022Product Two69
11/1/2022Product Two5
12/1/2022Product Two10
1/1/2023Product Two18
2/1/2023Product Two28
3/1/2023Product Two51
4/1/2023Product Two58
5/1/2023Product Two60
6/1/2023Product Two19
7/1/2023Product Two34
8/1/2023Product Two17
9/1/2023Product Two70
10/1/2023Product Two49
11/1/2023Product Two45
12/1/2023Product Two52
1/1/2024Product Two54
2/1/2024Product Two47
3/1/2024Product Two20
4/1/2024Product Two49
5/1/2024Product Two20
6/1/2024Product Two62
7/1/2024Product Two52
8/1/2024Product Two67
9/1/2024Product Two15
10/1/2024Product Two49
11/1/2024Product Two28
12/1/2024Product Two60
1/1/2020Product Two14
2/1/2020Product Two49
3/1/2020Product Two41
4/1/2020Product Two17
5/1/2020Product Two25
6/1/2020Product Two48
7/1/2020Product Two18
8/1/2020Product Two15
9/1/2020Product Two34
10/1/2020Product Two44
11/1/2020Product Two15
12/1/2020Product Two53
1/1/2021Product Two10
2/1/2021Product Two70
3/1/2021Product Two47
4/1/2021Product Two44
5/1/2021Product Two48
6/1/2021Product Two62
7/1/2021Product Two50
8/1/2021Product Two59
9/1/2021Product Two70
10/1/2021Product Two59
11/1/2021Product Two32
12/1/2021Product Two29
1/1/2022Product Two64
2/1/2022Product Two52
3/1/2022Product Two65
4/1/2022Product Two40
5/1/2022Product Two13
6/1/2022Product Two37
7/1/2022Product Two59
8/1/2022Product Two27
9/1/2022Product Two26
10/1/2022Product Two32
11/1/2022Product Two19
12/1/2022Product Two 
1/1/2023Product Two 
2/1/2023Product Two 
3/1/2023Product Two 
4/1/2023Product Two 
5/1/2023Product Two 
6/1/2023Product Two 
7/1/2023Product Two 
8/1/2023Product Two 
9/1/2023Product Two 
10/1/2023Product Two 
11/1/2023Product Two 
12/1/2023Product Two 
1/1/2024Product Two 
2/1/2024Product Two 
3/1/2024Product Two 
4/1/2024Product Two 
5/1/2024Product Two 
6/1/2024Product Two 
7/1/2024Product Two 
8/1/2024Product Two 
9/1/2024Product Two 
10/1/2024Product Two 
11/1/2024Product Two 
12/1/2024Product Two 
1/1/2020Product Two 
2/1/2020Product Two 
3/1/2020Product Two 
4/1/2020Product Two 
5/1/2020Product Two 
6/1/2020Product Two 
7/1/2020Product Two 
8/1/2020Product Two 
9/1/2020Product Two 
10/1/2020Product Two 
11/1/2020Product Two 
12/1/2020Product Two 
1/1/2021Product Two 
2/1/2021Product Two 
3/1/2021Product Two 
4/1/2021Product Two 
5/1/2021Product Two 
6/1/2021Product Two 
7/1/2021Product Two 
8/1/2021Product Two 
9/1/2021Product Two 
10/1/2021Product Two 
11/1/2021Product Two 
12/1/2021Product Two 
1/1/2022Product Two 
2/1/2022Product Two 
3/1/2022Product Two 
4/1/2022Product Two 
5/1/2022Product Two 
6/1/2022Product Two 
7/1/2022Product Two 
8/1/2022Product Two 
9/1/2022Product Two 
10/1/2022Product Two 
11/1/2022Product Two 
12/1/2022Product Two 
1/1/2023Product Two 
2/1/2023Product Two 
3/1/2023Product Two 
4/1/2023Product Two 
5/1/2023Product Two 
6/1/2023Product Two 
7/1/2023Product Two 
8/1/2023Product Two 
9/1/2023Product Two 
10/1/2023Product Two 
11/1/2023Product Two 
12/1/2023Product Two 
1/1/2024Product Two 
2/1/2024Product Two 
3/1/2024Product Two 
4/1/2024Product Two 
5/1/2024Product Two 
6/1/2024Product Two 
7/1/2024Product Two 
8/1/2024Product Two 
9/1/2024Product Two 
10/1/2024Product Two 
11/1/2024Product Two 
12/1/2024Product Two 
1/1/2020Product Three7
2/1/2020Product Three24
3/1/2020Product Three18
4/1/2020Product Three14
5/1/2020Product Three60
6/1/2020Product Three7
7/1/2020Product Three26
8/1/2020Product Three14
9/1/2020Product Three14
10/1/2020Product Three8
11/1/2020Product Three16
12/1/2020Product Three14
1/1/2021Product Three11
2/1/2021Product Three19
3/1/2021Product Three25
4/1/2021Product Three20
5/1/2021Product Three100
6/1/2021Product Three14
7/1/2021Product Three20
8/1/2021Product Three12
9/1/2021Product Three22
10/1/2021Product Three10
11/1/2021Product Three11
12/1/2021Product Three13
1/1/2022Product Three16
2/1/2022Product Three14
3/1/2022Product Three15
4/1/2022Product Three10
5/1/2022Product Three8
6/1/2022Product Three17
7/1/2022Product Three14
8/1/2022Product Three20
9/1/2022Product Three18
10/1/2022Product Three24
11/1/2022Product Three13
12/1/2022Product Three 
1/1/2023Product Three 
2/1/2023Product Three 
3/1/2023Product Three 
4/1/2023Product Three 
5/1/2023Product Three 
6/1/2023Product Three 
7/1/2023Product Three 
8/1/2023Product Three 
9/1/2023Product Three 
10/1/2023Product Three 
11/1/2023Product Three 
12/1/2023Product Three 
1/1/2024Product Three 
2/1/2024Product Three 
3/1/2024Product Three 
4/1/2024Product Three 
5/1/2024Product Three 
6/1/2024Product Three 
7/1/2024Product Three 
8/1/2024Product Three 
9/1/2024Product Three 
10/1/2024Product Three 
11/1/2024Product Three 
12/1/2024Product Three 
2 REPLIES 2
DataStraine
Advocate I
Advocate I

From my data, I am able to produce the image below (scrubbed of anything identifiable). The x-axis is the month and the y-axis is the value. The issue I'm having is that my line does not continue into the future. I believe it might be because the dates it is built from don't go into the future. Furthermore, I can't change the data from month to quarter and still get a result. I'm assuming the dark blue line is correct, but since I can't get it to work the way I intend, I don't know.

 

DataStraine_0-1672153814788.png

 

AlexisOlson
Super User
Super User

Linear regression is designed to fit data with a line, so I'm not sure what you think you should be getting. Can you show more clearly what you're getting and what you're expecting to get?

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors