{"id":15851,"date":"2018-08-15T12:08:15","date_gmt":"2018-08-15T19:08:15","guid":{"rendered":"https:\/\/devwww.3cloudsolutions.com\/post\/simple-linear-regression-in-power-bi-2\/"},"modified":"2024-01-08T10:51:44","modified_gmt":"2024-01-08T18:51:44","slug":"simple-linear-regression-in-power-bi","status":"publish","type":"post","link":"https:\/\/3cloudsolutions.com\/resources\/simple-linear-regression-in-power-bi\/","title":{"rendered":"Simple Linear Regression in Power BI"},"content":{"rendered":"<p>Combining <a href=\"https:\/\/powerbi.microsoft.com\/en-us\/get-started\/?&amp;OCID=AID719832_SEM_bHb24t0B&amp;lnkd=Google_PowerBI_Brand&amp;gclid=EAIaIQobChMI6cH7l_bL3AIVjGSGCh0nTAReEAAYASAAEgKRNPD_BwE\">Power BI<\/a> with statistics yields some very powerful results. In this post we\u2019ll show how easy it is to do Linear Regression with the Power BI tool.<\/p>\n<p>Linear Regression is a very useful statistical tool that helps us understand the relationship between variables and the effects they have on each other. It can be used across many industries in a variety of ways \u2013 from spurring value to gaining customer insight \u2013 to benefit business.<\/p>\n<p>The Simple Linear Regression model allows us to summarize and examine relationships between two variables. It uses a single <em>independent<\/em> variable and a single <em>dependent<\/em> variable and finds a linear function that predicts the <em>dependent <\/em>variable values as a function of the<em> independent<\/em> variables.<\/p>\n<p>We look at two statistical values to determine if there is a relationship between the two variables and how closely related they are.<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" style=\"width: 805px;\" src=\"https:\/\/3cloudsolutions.com\/wp-content\/uploads\/2022\/11\/Simple-Linear-Regression-in-Power-BI-1.png\" alt=\"Simple Linear Regression in Power BI\" width=\"805\" \/><\/p>\n<p>The <a href=\"https:\/\/en.wikipedia.org\/wiki\/Correlation_coefficient\">Coefficient of Correlation<\/a> is a statistic we use to determine if there is a relationship between two variables. The output of this statistic equals somewhere between 1 and -1. The closer to 1 the number is, the more positively related the variables are. As in, if X increases, Y increases. The closer to -1 the number is, the more negatively related the variables are. If X increases, Y decreases.<\/p>\n<p>The <a href=\"https:\/\/en.wikipedia.org\/wiki\/Coefficient_of_determination\">Coefficient of Determination<\/a> is a related statistic that then tells us how well our model fits the data. This statistic is always between 0 and 1, and the closer to 1 the value is, the better our model fits the data set.<\/p>\n<p>So how do we perform Linear Regression in Power BI? First, we make a scatter plot and visually examine the data to see if we think there is a relationship.<\/p>\n<h2>Scatter Plot in Power BI<\/h2>\n<p>In this example, I used my own financial data to see if I could understand the best ways to save money each month. This analysis shows the relationship between the number of times I went to restaurants and the money spent in this category of my monthly budget.<\/p>\n<p>Food is my second highest budget category each month. I don\u2019t think the bank will cut my mortgage down to save me a bit each month, so my restaurant spending seems like the next best place to start. Here\u2019s how to follow along using your own data:<\/p>\n<h2>Create a Scatter Plot<\/h2>\n<p style=\"padding-left: 30px;\">1. Click the <strong>Scatter Plot<\/strong> visualization and add your columns. In my case, I used <em>Year Month<\/em>, <em>Count Days<\/em>, and <em>Amount <\/em>to determine how often I\u2019m dining out and the associated cost.<\/p>\n<p><img decoding=\"async\" style=\"width: 251px; display: block; margin-left: auto; margin-right: auto;\" src=\"https:\/\/3cloudsolutions.com\/wp-content\/uploads\/2022\/11\/scatter-plot-1.png\" alt=\"scatter plot\" width=\"251\" \/><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"background-color: transparent;\">2. From the Analytics pane add a <\/span><strong style=\"background-color: transparent;\">Trend Line<\/strong><span style=\"background-color: transparent;\">.<\/span><span style=\"background-color: transparent;\">\u00a0<\/span><\/p>\n<p><img decoding=\"async\" style=\"width: 289px; display: block; margin-left: auto; margin-right: auto;\" src=\"https:\/\/3cloudsolutions.com\/wp-content\/uploads\/2022\/11\/trend-line-1.png\" alt=\"trend line\" width=\"289\" \/><\/p>\n<p>The results should look something like this:<\/p>\n<p><img decoding=\"async\" style=\"width: 754px; display: block; margin-left: auto; margin-right: auto;\" src=\"https:\/\/3cloudsolutions.com\/wp-content\/uploads\/2022\/11\/results.png\" alt=\"results\" width=\"754\" \/><\/p>\n<p>There definitely seems to be a correlation between my dining out and my increased expenses, so I\u2019ll make the calculations to see if I\u2019m right.<\/p>\n<h2>Creating the Coefficient of Correlation<\/h2>\n<ol>\n<li>Right click on the table and click <strong>New quick measure<\/strong>.<\/li>\n<\/ol>\n<p><img decoding=\"async\" style=\"width: 254px; display: block; margin-left: auto; margin-right: auto;\" src=\"https:\/\/3cloudsolutions.com\/wp-content\/uploads\/2022\/11\/new-quick-measure-1.png\" alt=\"new quick measure\" width=\"254\" \/><\/p>\n<ol start=\"2\">\n<li>Select <strong>Correlation coefficient<\/strong> from the Calculations under \u201cMathematical operations\u201d.<\/li>\n<\/ol>\n<p><img decoding=\"async\" style=\"width: 383px; display: block; margin-left: auto; margin-right: auto;\" src=\"https:\/\/3cloudsolutions.com\/wp-content\/uploads\/2022\/11\/correlation-coefficient-1.png\" alt=\"correlation coefficient\" width=\"383\" \/><\/p>\n<ol start=\"3\">\n<li>Select the <strong>Category<\/strong>, <strong>Measure X<\/strong>, and <strong>Measure Y<\/strong>. These columns will match the dot plot we created earlier.<\/li>\n<\/ol>\n<p><img decoding=\"async\" style=\"width: 460px; display: block; margin-left: auto; margin-right: auto;\" src=\"https:\/\/3cloudsolutions.com\/wp-content\/uploads\/2022\/11\/category-measure-1.png\" alt=\"category measure\" width=\"460\" \/><\/p>\n<p>The Coefficient of Correlation will now be available in your table, and it\u2019s ready for use.<\/p>\n<p><img decoding=\"async\" style=\"width: 429px; display: block; margin-left: auto; margin-right: auto;\" src=\"https:\/\/3cloudsolutions.com\/wp-content\/uploads\/2022\/11\/coefficient-of-correlation-1.png\" alt=\"coefficient of correlation\" width=\"429\" \/><\/p>\n<h2>Creating the Coefficient of Determination<\/h2>\n<p>In this case, a quick measure would be overkill. The <em>Coefficient of Correlation<\/em> is notated as the letter R. The Coefficient of Determination is R<sup>2<\/sup>.<\/p>\n<p style=\"text-align: center;\"><strong>Coefficient of Determination = [Coefficient of Correlation]<sup>2<\/sup><\/strong><\/p>\n<p>I now have two statistics based on my data set that tell me how and to what degree my X (<em>Count Days<\/em>) and Y (<em>Amount<\/em>) variables are related.<\/p>\n<p><img decoding=\"async\" style=\"width: 687px; display: block; margin-left: auto; margin-right: auto;\" src=\"https:\/\/3cloudsolutions.com\/wp-content\/uploads\/2022\/11\/coefficient-of-determination-1.png\" alt=\"coefficient of determination\" width=\"687\" \/><\/p>\n<p>As we can see, per our definitions above, both the Coefficient of Correlation and Determination are very close to 1. This means <em>Count Days<\/em> is certainly related to <em>Sum of Amount<\/em> and does a very good job of predicting how much I\u2019ll spend given the number of days I eat out every month.<\/p>\n<h2>Model\u2019s Many Benefits<\/h2>\n<p>Besides offering basic budget insight, Simple Linear Regression analysis is useful for a wide variety of verticals and business cases. Combining it with Power BI can create powerful analytical capabilities.<\/p>\n<p>We can use Linear Regression to analyze the effect of marketing on sales and profits. Or it can clue a company in to how raising prices may affect a consumer\u2019s buying habits. Insurance companies can also use this technique to assess risk between customer demographics and insurance claims.<\/p>\n<h3>Looking to Learn More?<\/h3>\n<p>If you are interested harnessing statistics with Power BI to boost your business, <a href=\"\/get-started\/\">contact us<\/a> today.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Combining Power BI with statistics yields some very powerful results. In this post we\u2019ll show how easy it is to do Linear Regression with the Power BI tool. Linear Regression helps us understand the relationship between variables and the effects they have on each other.<\/p>\n","protected":false},"author":21,"featured_media":14264,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"content-type":"","footnotes":""},"categories":[260],"tags":[273],"class_list":["post-15851","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-ai","tag-power-bi","topics-blog"],"acf":[],"_links":{"self":[{"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/posts\/15851","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/comments?post=15851"}],"version-history":[{"count":0,"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/posts\/15851\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/media\/14264"}],"wp:attachment":[{"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/media?parent=15851"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/categories?post=15851"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/tags?post=15851"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}