Linear Regression In Power BI

Introduction

 
In this article you will see how to perform linear regression in Power BI. Linear regression is an extremely valuable measure that help us to understand connection among variables and the impacts they have on one another. It can be used across many industries in a variety of ways – from spurring value to acquiring client understanding –in order  to profit businesses.
 
The Simple Linear Regression model permits us to sum up and look at relationship between two variables. To find linear regression there will be an independent variable and a dependent variable. It uses it to finds a linear function that predicts the dependent variable values as a function of the independent variables.
 
In a previous article I have shown you how to find ‘correlation coefficient’ that is used to determine the relation between two variables. See that article here.
 
The value of correlation coefficient lies between -1 to 1. Negative means if X increases, Y decreases or positive means If X increases, Y increases.
 
To perform linear regression, follow the below steps.
 
Step 1
 
To show linear regression I used sales data. I have imported my table from sql server. I have written a separate article on how to import data from sql server.
 
Linear Regression in Power BI 
 
Step 2
 
Our second step will be creating scatter plot. You can find scatter plot in visualization panel. Click on it and fields into it. I am using month of ‘ModifiedDate’ column, ‘OrderQty’ on X-axis and ‘UnitPrice’ on Y-axis.
 
Linear Regression in Power BI 
 
Step 3
 
Now I am going to add a trend line into it. To add trend line go to ‘Analytics’ tab below the visualization and click on ‘Trend line’ again click on ‘Add’. Rename the line, select any color and style for line. A line will be added on scatter plot.
 
Linear Regression in Power BI 
 
This line is shown the correlation between two values and it is positive. We can also add correlation coefficient in this report to check it. I have already written a separate article on ‘Correlation coefficient’. Add a quick measure and click on ‘correlation coefficient’. Select the same fields that we have used for linear regression.
 
Linear Regression in Power BI 
 
Select ‘Card’ visualization to show the value of ‘correlation coefficient’.
 
Linear Regression in Power BI 
 

Summary

 
Linear Regression is helpful for a wide assortment of verticals and business cases. Joining it with Power BI can make amazing logical abilities. We can utilize Linear Regression to break down the impact of promoting on deals and benefits. Or on the other hand it can clue  an organization into how raising costs may influence a customer's purchasing propensities. Insurance agencies can likewise utilize this method to evaluate connections between client socioeconomics and protection claims.