# Calculate SLOPE value in PowerBI for given x and y values



## vds1 (Jun 7, 2021)

Hello,

Thank you for looking into my question. 

I have series of x_value and y_value. I am looking for excel equivalent SLOPE function in PowerBI. Can you please help me with measure to calculate SLOPE for below data points?

*Expected Output SLOPE (m) = 1.34556304295796*



*y_value**x_value*0.020.020.00-0.010.000.010.090.06


----------



## vds1 (Jun 7, 2021)

I was able to find the answer in web. TblData is the name of the Table with x_value and y_value as field. The Slope can be calculated as below:


```
Slope =
Var AvgX = CALCULATE(AVERAGE(TblData[x_value]),all(TblData))
Var AvgY = CALCULATE(AVERAGE(TblData[y_value]),all(TblData))
RETURN DIVIDE(sumx(TblData,(TblData[x_value]-AvgX) * (TblData[y_value] - AvgY)),
              sumx(TblData,(TblData[x_value] - AvgX) * (TblData[x_value] - AvgX)))
```


----------

