{"id":196,"date":"2020-09-08T23:24:41","date_gmt":"2020-09-08T19:54:41","guid":{"rendered":"http:\/\/mahshad.pro\/?p=196"},"modified":"2024-09-02T22:05:27","modified_gmt":"2024-09-02T18:35:27","slug":"creating-a-business-intelligence-dashboard-with-microsoft-power-bi","status":"publish","type":"post","link":"https:\/\/mahshad.pro\/?p=196","title":{"rendered":"Creating a business intelligence dashboard with Microsoft Power\u00a0BI"},"content":{"rendered":"\n<p>This tutorial is also published on <a href=\"https:\/\/medium.com\/@mahshadn\/creating-a-business-intelligence-dashboard-with-microsoft-power-bi-f64053eaa000?source=friends_link&amp;sk=7cbfe536855e90fb9d04d51bdff6ae73\">Medium.com<\/a><\/p>\n\n\n\n<p>Let&#8217;s assume you are a business owner or manager and your operations generate large amount of data every day. Days go by and the amount of data increases. You may be miles away but nowadays many know how valuable the data can be to organizations and companies and how the right usage of data can add value to the organization.<\/p>\n\n\n\n<p>You may take a look at those data stored on your computer and see lots of numbers and text in different tables, which seems to be difficult to understand anything. \u201cData visualization\u201d can help to depict what has happened within the company\u2019s operation and assist the decision makers to grasp \u201cinsights\u201d from the data which can help them make more effective and calculated decisions.<\/p>\n\n\n\n<p>Power BI is a robust tool that have made it easy to connect to different types of data sources and import the data to the model. You can create relationships between data tables and make queries to provide necessary manipulations in the data. These changes are not usually done for the imported data, but are to create new tables, columns or measures. Power BI uses the DAX language which is similar to what is used in MS Excel.<\/p>\n\n\n\n<p>In this practice we will be using a complaints dataset from an insurance company. We will create a BI dashboard to provide information and insights laid out in that dataset. This dataset was taken from <a rel=\"noreferrer noopener\" href=\"https:\/\/forum.enterprisedna.co\/t\/power-bi-challenge-6-insurance-complaints\/9954\" target=\"_blank\">EnterpriseDNA Power BI challenge 6<\/a>. The main objectives in this challenge is to provide:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The ability to see status changes and when they happened<\/li>\n\n\n\n<li>Complaints broken down by the dimensions<\/li>\n\n\n\n<li>Client Satisfaction<\/li>\n\n\n\n<li>Worst offending brokers<\/li>\n<\/ol>\n\n\n\n<p>Also the data provider prefers to have the insights which belongs to no older than two years ago.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Dataset<\/h4>\n\n\n\n<p>The dataset consists of a twelve different tables, including a table named \u201cComplains Data\u201d which is the main table and includes complaint ID, date, broker, customer, client satisfaction and more columns. Each dimension has a separate table that includes data regarding that dimension. For instance we have customers table, brokers, complaint status, regions, etc. Since each complaint\u2019s status may be changed over the progress period, there is a separate table that includes the complaint IDs and the dates that their statuses has been changed.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"653\" src=\"http:\/\/mahshad.pro\/wp-content\/uploads\/dataset-1024x653.png\" alt=\"\" class=\"wp-image-197\" srcset=\"https:\/\/mahshad.pro\/wp-content\/uploads\/dataset-1024x653.png 1024w, https:\/\/mahshad.pro\/wp-content\/uploads\/dataset-300x191.png 300w, https:\/\/mahshad.pro\/wp-content\/uploads\/dataset-768x489.png 768w, https:\/\/mahshad.pro\/wp-content\/uploads\/dataset-400x255.png 400w, https:\/\/mahshad.pro\/wp-content\/uploads\/dataset-800x510.png 800w, https:\/\/mahshad.pro\/wp-content\/uploads\/dataset.png 1285w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\"> complaints dataset <\/figcaption><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Relationships<\/h4>\n\n\n\n<p>The dataset is almost cleaned and does not need much of manipulations. But in order to calculate some variables for some of the data, we need to create new columns and measures after importing it into the Power BI. First of all we need to review the dataset and understand how tables are related to each other and then create the right relationships and to make sure Power BI has created the correct relationships initially.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"774\" src=\"http:\/\/mahshad.pro\/wp-content\/uploads\/rltship-1024x774.png\" alt=\"\" class=\"wp-image-198\" srcset=\"https:\/\/mahshad.pro\/wp-content\/uploads\/rltship-1024x774.png 1024w, https:\/\/mahshad.pro\/wp-content\/uploads\/rltship-300x227.png 300w, https:\/\/mahshad.pro\/wp-content\/uploads\/rltship-768x581.png 768w, https:\/\/mahshad.pro\/wp-content\/uploads\/rltship-400x302.png 400w, https:\/\/mahshad.pro\/wp-content\/uploads\/rltship-800x605.png 800w, https:\/\/mahshad.pro\/wp-content\/uploads\/rltship.png 1066w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\"> Making relationships between related tables <\/figcaption><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Calculations<\/h4>\n\n\n\n<p>In order to calculate the duration for each complaint status, we will need the Power BI to check the status dates for each complaint ID and return the number of days each status lasted. We will also need the number of times that status has changed for each complaint ID, which we can have it by using below formula:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>StatusDuration =\nvar _CurrentTaskTime = CALCULATE( SELECTEDVALUE('Status History Data'&#91;StatusDate]))\nvar _PreviousTaskTime = CALCULATE(\n   MAX('Status History Data'&#91;StatusDate]),\n   ALLEXCEPT('Status History Data', 'Status History Data'&#91;ComplaintID]),\n   'Status History Data'&#91;StatusDate] &lt; _CurrentTaskTime)\nvar _timeDifference =\n   IF( ISBLANK(_PreviousTaskTime),\n   0,\n   DATEDIFF(_PreviousTaskTime, _CurrentTaskTime, DAY))\nreturn _timeDifference<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>Above, we allocate a variable called <code>CurrentTaskTime<\/code> to store the date for the selected value, and another variable called <code>PreviousTaskTime<\/code> to grab the maximum date just before the current date for the selected complaint ID, which is set to be smaller than current date. Eventually, the difference between two variables is measured and returned as the output value.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"790\" height=\"338\" src=\"http:\/\/mahshad.pro\/wp-content\/uploads\/formula1.png\" alt=\"\" class=\"wp-image-199\" srcset=\"https:\/\/mahshad.pro\/wp-content\/uploads\/formula1.png 790w, https:\/\/mahshad.pro\/wp-content\/uploads\/formula1-300x128.png 300w, https:\/\/mahshad.pro\/wp-content\/uploads\/formula1-768x329.png 768w, https:\/\/mahshad.pro\/wp-content\/uploads\/formula1-400x171.png 400w\" sizes=\"auto, (max-width: 790px) 100vw, 790px\" \/><figcaption class=\"wp-element-caption\"> Calculating the number of days each status lasted <\/figcaption><\/figure>\n\n\n\n<p>And for the number of status changes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Number of Status Changes = CALCULATE(\nCOUNT(&#91;ComplaintID]),\nFILTER('Status History Data', &#91;ComplaintID] =\nEARLIER('Status History Data'&#91;ComplaintID])))<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Visualization<\/h4>\n\n\n\n<p>Below page is the dashboard\u2019s first page:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"574\" src=\"http:\/\/mahshad.pro\/wp-content\/uploads\/pg1-1024x574.png\" alt=\"\" class=\"wp-image-200\" srcset=\"https:\/\/mahshad.pro\/wp-content\/uploads\/pg1-1024x574.png 1024w, https:\/\/mahshad.pro\/wp-content\/uploads\/pg1-300x168.png 300w, https:\/\/mahshad.pro\/wp-content\/uploads\/pg1-768x431.png 768w, https:\/\/mahshad.pro\/wp-content\/uploads\/pg1-400x224.png 400w, https:\/\/mahshad.pro\/wp-content\/uploads\/pg1-800x448.png 800w, https:\/\/mahshad.pro\/wp-content\/uploads\/pg1.png 1329w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\"> First page of the dashboard <\/figcaption><\/figure>\n\n\n\n<p>If you have numeric values in a column it is pretty straight forward to make conditional formatting in the tables. But what if there are text values and we want to have formatted table based on the text values?<\/p>\n\n\n\n<p>For example, Based on <code>CompletionTime <\/code>I made a new column to indicate if each complaint is completed or still in progress. I also added a conditional column so that if the value is \u201cCompleted\u201d put number 2 and if the value is \u201cIn Progress\u201d put number 1. Now based on the numbers I can format the complaint status to highlight yellow if in progress and blue if the complaint is completed.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>StatusCode = IF(&#91;Complaint Status] = \"Completed\", 2, 1)<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"933\" height=\"659\" src=\"http:\/\/mahshad.pro\/wp-content\/uploads\/bgrnd.png\" alt=\"\" class=\"wp-image-201\" srcset=\"https:\/\/mahshad.pro\/wp-content\/uploads\/bgrnd.png 933w, https:\/\/mahshad.pro\/wp-content\/uploads\/bgrnd-300x212.png 300w, https:\/\/mahshad.pro\/wp-content\/uploads\/bgrnd-768x542.png 768w, https:\/\/mahshad.pro\/wp-content\/uploads\/bgrnd-400x283.png 400w, https:\/\/mahshad.pro\/wp-content\/uploads\/bgrnd-800x565.png 800w\" sizes=\"auto, (max-width: 933px) 100vw, 933px\" \/><figcaption class=\"wp-element-caption\"> Conditional formatting window <\/figcaption><\/figure>\n\n\n\n<p>I dedicated the second page to show insights about client satisfaction:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"573\" src=\"http:\/\/mahshad.pro\/wp-content\/uploads\/pg2-1024x573.png\" alt=\"\" class=\"wp-image-202\" srcset=\"https:\/\/mahshad.pro\/wp-content\/uploads\/pg2-1024x573.png 1024w, https:\/\/mahshad.pro\/wp-content\/uploads\/pg2-300x168.png 300w, https:\/\/mahshad.pro\/wp-content\/uploads\/pg2-768x430.png 768w, https:\/\/mahshad.pro\/wp-content\/uploads\/pg2-400x224.png 400w, https:\/\/mahshad.pro\/wp-content\/uploads\/pg2-800x448.png 800w, https:\/\/mahshad.pro\/wp-content\/uploads\/pg2.png 1316w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\"> Second page of the dashboard <\/figcaption><\/figure>\n\n\n\n<p>In the line chart in top of the page, I visualized the change of client satisfaction over the course of time. For this, I had to represent the average percentage of satisfied and not satisfied clients in each year. So I created two measures for each line as below:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Average Not Satisfied = var TotalNSA = CALCULATE( COUNT('Complains Data'&#91;ID]), 'Complains Data'&#91;Client Satisfaction] = \"NSA\")\nvar TotalID = COUNT('Complains Data'&#91;ID])\nreturn TotalNSA\/TotalID<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>I did the same for satisfied customers as well.<\/p>\n\n\n\n<p><strong>Note:<\/strong> If you are using the <strong>ArcGIS<\/strong> maps in your report, please be aware that currently those maps will not be shown when you publish the report on the web. You can use filled map instead till Microsoft supports the <strong>ArcGIS<\/strong> maps in published reports.<\/p>\n\n\n\n<p>The third page is dedicated to complaints timeline and what can better visualize the tasks over the course of time than a <strong>Gantt chart<\/strong>? You can add the Gantt chart visual directly from Power BI via \u201cGet more visuals\u201d menu.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"574\" src=\"http:\/\/mahshad.pro\/wp-content\/uploads\/p3-1024x574.png\" alt=\"\" class=\"wp-image-203\" srcset=\"https:\/\/mahshad.pro\/wp-content\/uploads\/p3-1024x574.png 1024w, https:\/\/mahshad.pro\/wp-content\/uploads\/p3-300x168.png 300w, https:\/\/mahshad.pro\/wp-content\/uploads\/p3-768x431.png 768w, https:\/\/mahshad.pro\/wp-content\/uploads\/p3-400x224.png 400w, https:\/\/mahshad.pro\/wp-content\/uploads\/p3-800x449.png 800w, https:\/\/mahshad.pro\/wp-content\/uploads\/p3.png 1314w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\"> Complaint timeline is visualized within a gantt chart <\/figcaption><\/figure>\n\n\n\n<p>The labels on the top are being changed and show the information associated with the selected complaint ID. In Power BI, in order to enable a label to show a specific value associated with the selected filter, you will need to define a measure to do so. For instance, below code will create a measure that shows the <code>Client Satisfaction<\/code> associated with the selected <code>Complaint ID<\/code> and if no ID has been selected, it will show \u201cNot Selected\u201d.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SelectedClientSatisfaction = IF( ISFILTERED('Status History Data'&#91;ComplaintID]),\nSELECTEDVALUE('Complains Data'&#91;Client Satisfaction]), \"Not Selected\")<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>Finally, we will create a cover page for your dashboard and link any pictures to any page in your report, or even a web page, using Action section in \u201cFormat Image\u201d section.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"574\" src=\"http:\/\/mahshad.pro\/wp-content\/uploads\/complaints-dashboard1-1024x574.png\" alt=\"\" class=\"wp-image-538\" srcset=\"https:\/\/mahshad.pro\/wp-content\/uploads\/complaints-dashboard1-1024x574.png 1024w, https:\/\/mahshad.pro\/wp-content\/uploads\/complaints-dashboard1-300x168.png 300w, https:\/\/mahshad.pro\/wp-content\/uploads\/complaints-dashboard1-768x431.png 768w, https:\/\/mahshad.pro\/wp-content\/uploads\/complaints-dashboard1-400x224.png 400w, https:\/\/mahshad.pro\/wp-content\/uploads\/complaints-dashboard1-800x449.png 800w, https:\/\/mahshad.pro\/wp-content\/uploads\/complaints-dashboard1.png 1327w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\"> <\/figcaption><\/figure>\n\n\n\n<p>Finally, you can access the live published dashboard via <a href=\"https:\/\/app.powerbi.com\/view?r=eyJrIjoiZWFjN2I2OGEtMmU4Ni00NTIwLWE4YWUtZTBjYzQzNTU3MjQ2IiwidCI6Ijg5NTFiNjRmLWYwYzctNGYxMi1hNmIxLTNiYzkxZmZmYjQyZSJ9\" target=\"_blank\" rel=\"noreferrer noopener\">this link.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to create a business intelligence dashboard using Microsoft Power BI<\/p>\n","protected":false},"author":1,"featured_media":538,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[28,40],"tags":[42,32,43,41],"class_list":["post-196","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","category-works","tag-business-intelligence","tag-data-visualization","tag-dax","tag-power-bi","has-thumbnail"],"_links":{"self":[{"href":"https:\/\/mahshad.pro\/index.php?rest_route=\/wp\/v2\/posts\/196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mahshad.pro\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mahshad.pro\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mahshad.pro\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mahshad.pro\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=196"}],"version-history":[{"count":7,"href":"https:\/\/mahshad.pro\/index.php?rest_route=\/wp\/v2\/posts\/196\/revisions"}],"predecessor-version":[{"id":540,"href":"https:\/\/mahshad.pro\/index.php?rest_route=\/wp\/v2\/posts\/196\/revisions\/540"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mahshad.pro\/index.php?rest_route=\/wp\/v2\/media\/538"}],"wp:attachment":[{"href":"https:\/\/mahshad.pro\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mahshad.pro\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mahshad.pro\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}