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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

y=mx+c

I want to use y= mx+c to calculate y on the dates that are in b/w the years. so first how I will calculate "m" and "C"

 

using given table.

 

Dateyxcalculated column mcalculated comumn C
12/31/20161467148258m = (y3-y2/x3-x2)y=(m*x)+C
12/31/20171486401274How to use cell level data from y and x column to calculate m 
12/31/20181498969284 
12/31/20191524506304 
12/31/20201547590322 
12/31/20211577861343 
12/31/20221713452429 
12/31/20231856239493 

 

Once thats done, how will I enter value in y in a different table, as it get calculated from the above table.

 

Dateyx
12/31/20161467148258
1/10/2017 260
5/6/2017 264
10/11/2017 270
12/31/20171486401274
2/2/2018 275
3/4/2018 278
8/10/2018 282
12/31/20181498969284
2/19/2019 290
3/7/2019 264
8/11/2019 300
12/31/20191524506304
1 ACCEPTED SOLUTION

Hi, @Anonymous 

 

You can try the following methods.

Column:

 

m = LOOKUPVALUE('Table'[m],'Table'[Date],[Date])
C = LOOKUPVALUE('Table'[C],'Table'[Date],[Date])

 

vzhangti_0-1667887020686.png

 

M1 = MINX(FILTER('Table (2)',EARLIER('Table (2)'[Date])<=[Date]),[m])
C1 = MAXX(FILTER('Table (2)',EARLIER('Table (2)'[Date])<=[Date]),[C])
Y1 = [M1]*[x]+[C1]

 

vzhangti_1-1667887078406.png

You said: "for example for 1/10/2017 y = (1203.31 * 260) + 1156693.38 =1469553.98".

It is not exactly equal to this value because both M1 and C1 have hidden decimals.

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

You can try the following methods.
Column:

Previous y = MAXX(FILTER('Table',[Date]<EARLIER('Table'[Date])),[y])
Previous x = MAXX(FILTER('Table',[Date]<EARLIER('Table'[Date])),[x])

vzhangti_0-1667466661121.png

m = IF([Previous x]<>BLANK()&&[Previous y]<>BLANK(),DIVIDE([y]-[Previous y],[x]-[Previous x]))
C = IF([m]<>BLANK(),[y]-([m]*[x]))

vzhangti_1-1667466705878.png

Is this the result you expect?

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Any update on this please? Really appricate if you can help me

Anonymous
Not applicable

that's half of my question. now with the data you provided we need to fill Y = MX+C in another table where dates are within those years ending values to show the progress of Y. Can you help me with that please?

 

so if the date is in b/w 12/31/2016 && 12/31/2017, it will take the X multply m from 12/31/2017 and add C from 12/31/217 to it

for example for 1/10/2017 y = (1203.31 * 260) + 1156693.38 = 1469553.98

 

Date

yx
12/31/20161467148258
1/10/2017 260
5/6/2017 264
10/11/2017 270
12/31/20171486401274
2/2/2018 275
3/4/2018 278
8/10/2018 282
12/31/20181498969284
2/19/2019 290
3/7/2019 264
8/11/2019 300
12/31/20191524506304

Hi, @Anonymous 

 

You can try the following methods.

Column:

 

m = LOOKUPVALUE('Table'[m],'Table'[Date],[Date])
C = LOOKUPVALUE('Table'[C],'Table'[Date],[Date])

 

vzhangti_0-1667887020686.png

 

M1 = MINX(FILTER('Table (2)',EARLIER('Table (2)'[Date])<=[Date]),[m])
C1 = MAXX(FILTER('Table (2)',EARLIER('Table (2)'[Date])<=[Date]),[C])
Y1 = [M1]*[x]+[C1]

 

vzhangti_1-1667887078406.png

You said: "for example for 1/10/2017 y = (1203.31 * 260) + 1156693.38 =1469553.98".

It is not exactly equal to this value because both M1 and C1 have hidden decimals.

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks for reply. For M1 and C1, it shows minx and maxx as the number is incremental or decremental, what if it is not incremental or decremental, how can we calculate M1 and C1, please?

Anonymous
Not applicable

I didn't get that. First we need to calculate m on the first table. y value from current cell to previous cell and x value from current to previous cell. Can you help me with that from first table. and once that is calculated then need to insert  y values on the dates that dont it based on the top table when there is no common lookup value. 

HoangHugo
Solution Specialist
Solution Specialist

Hi

 

New Table = SUMMARIZE ([data table], [Date column],[Y column],[X column])

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.