Saturday, January 21, 2017

Diving deep into data analytics with Power BI: Tabular Visualization using MS Excel data

This tutorial is all about making use of Power BI for data analytics. To start, again, its all about data. Interestingly I will be using sample data set that I found from Tableau online samples. Yes, I said Tableau, just because I download it from their site, but data is from ESPN. The title of dataset is "Global Sport Finances" and description says "The top paying pro sports teams and the top paid athletes via ESPN." The data set can be found at Tableau Sample Data Sets: Global Sport Finances given that you are signed-in into their public website, and yes it free. Please go ahead. Why I selected this dataset, the only reason is that I am interested in sports and this will spark my interest in getting insight from data. The data is in Microsoft Excel Format and it contains two two data sheets names "Top teams Payroll List" and "Top Athlete Salaries". "Top teams Payroll List" rank teams according to their "Average Annual pay per player". The attributes/columns/fields in this data sheet are:

Rank
Last Year's Rank
Team, League
Average Annual pay per player
% change from last year's survey
Total Payroll
Rank of Total Payroll
Average player 5 year earnings
% change over last 5 years

"Top Athlete Salaries" data sheet list the top athlete earners in 2014. For me, interestingly, the name is from Boxing. I was expecting someone from Golf, Tennis, Formula 1 or Soccer. The fields in this data sheet are:

Athlete
2014 Pay
Salary/Winnings
Endorsements
Sport

During this tutorial, I will be working with Power BI Desktop. Your startup screen should look like the one given in Figure 1.

Figure 1: Welcome Screen for Power BI Desktop
First task, again its all about data. Get data into your Power BI Desktop. Power BI given us freedom to use many (almost all) different types of data sources. Just go ahead with Microsoft Excel for this time. The dialog should look like as shown in Figure 2.

Figure 2: Get Data Dialog
Once you finish selecting the Excel file. The navigator dialog will show you all the data sheets that are available in the selected excel fine and it will also give you a preview of the data as shown in Figure 3. To load the data just click "Load".

Figure 3: Navigator with Data Preview
Once you will get finished with loading data, your Power BI Desktop windows should look like as shown in Figure 4. Please don't forget to save you work before you move forward. You will find the loaded data sheet information of the right side of the window under title of Fields.

Figure 4: Power BI Desktop Designer View

We will start with simple plain examples, and then will move forward gradually increasing the complexity of our analytics. For those obsessed with large and complex data, please keep patience. The target of this tutorial to get individuals learn from scratch. We will first start with simple tabular representation of "Top Athlete Salaries" data. We will first focus on this data sheet for exploring all important features of Power Bi Desktop and then we will move ahead with other data sheet and probably other data sets. On right hand side of window shown in Figure 4, you can observe the Visualizations pane. Before we move forward, do observe that we already have two types of filters available in Visualizations pane, i.e., Page level filters and Report level filters. Just keep simple rule in mind, irrespective of what reporting tool you use, we have to think at each level of report that what data will contribute for creation/rendering of given level. The most common levels are Report -> Page -> Rows. However, we also have other possible levels depending on type of report, such as column and group. If you want some work done or data presented at each of these level, their frequency will be defined by the level selected. For example, Report means to be executed/done when report is rendered, similarly Page means to be executed/done at each page, and similarly Row means to be executed/done for each row. Now, before you get bored with this conceptual discussion. Select the Table visualization from Visualization pane as shown in Figure 5. Add all fields by selecting it from Fields pane. You can observe that on addition of Table visualization, an additional filter of visualization level filter is added in Filters area of Visualization pane as well as Values region is added in Visualization pane where you can observe that each field that you will add to your report, it will get listed in Values region.

Figure 5: Adding Table Visualization in Power BI Desktop
After adding all fields. Resize the table in designer to a suitable width and height using the selectors around the table. Now click on any area in designer and select the format symbol in the Visualization pane. The format symbol is "Paint Roller". Just click it. Update the Page Information and Page Size values according to your design preferences. Be critical about the page size information. If you visualization is not intended for printing purpose then you can set it according to your visualization need, however, if it is to be paper printed regularly, do make sure you have selected the size the prints best according to your client/business needs.  I update the name field in Page Information and Type field to Letter in Page Size. After completing the page formatting, select the table in designer view and set the formatting for the table. I recommend to increase the size of text from 8 to 12 in General properties. You can also set the height, width, as well as x and y positions to display table. You can change table style, I prefer the Bold Header style. Grid setting enables use to set either we want to display grid or not and how it should be displayed. I prefer to display both horizontal and vertical grid for this report. You can explore other options on your own, but don't forget to enable the title for the report. Also put a suitable title. The updated view of report in the design mode is shown in Figure 6.

Figure 6: Tabular Report using Power BI
To reorder the column arrangement, one can simply drag and move columns to required position. We still lack an information in our tabular view. What is the rank? Yes, it is obvious that first row is for individual with first rank, but visualization is about conveying maximum information in first glimpse. To get this done, click on Home -> Edit Queries in the toolbar as shown in Figure 7.

Figure 7: Edit Queries Button in Home Toolbar


As you will click the Edit Queries Button, a separate Query Editor window will open. In the toolbar above, click on the Add Column tab. Click on Index Column and select "From 1" as shown in Figure 8.

Figure 8: Adding Index Column
After adding the index column, don't forget to rename it and change its data type into Whole Number. You must observe that every action that you perform in Query Editor has representative step added into Applied Steps region in Query Settings pane on the right hand side. Similarly, observe that for each action there is a representative DAX expression that can be found at top of the tabular data view underneath the toolbar. Don't forget to click on the apply button in the Home toolbar to apply the changes. Or you can simply click the save icon in the top menu bar and Power BI will confirm either you want to apply changes or revert them. After completing the apply and close operation in the Query Editor, don't forget to add the new added Rank column into your report at the correct position. Also ensure that you report is sorted on Rank column in ascending order. Now its time to publish our report online. Before you proceed, please create you profile on Power BI public, yes, its free. For Microsoft Power BI account creation, visit Sign in | Microsoft Power BI. Once you are done with you account creation click on Home -> Publish button in toolbar. It will ask you for credentials to sign-in into your Power BI public account as shown in Figure 9 and 10. Once you have provided the correct credentials, it will show you the success prompt as shown in Figure 11, if every think worked correctly for you.

Figure 9: Power BI Desktop Sign-in Prompt for Power BI Public
Figure 10: Power BI Desktop Password Prompt for Power BI Public
Figure 11: Power BI Desktop Successful Publish to Power BI Public Prompt
Good, now its time to use you published report on your online resources. Every work that we publish from Power BI Desktop is available and accessible on your online Power BI account as shown in Figure 12.

Figure 12: Power BI Public
Click on the newly published report and the report will be viewed online. Good part is that you can still edit your report online in the browser. But, beware, you changes will not automatically be transferred to your local copy. I personally prefer to always perform changes locally and uploading the latest version. But hay, wait a moment. All what we have done using Power BI Desktop can also be done online your Power BI online account. We will use the online version in our next tutorial. To use your report in other online systems, generate the embed code using the File -> Publish to Web menu as shown in Figure 13. A new dialog window will appear with option to create embed code as shown in Figure 14. Once you click on the Create embed code, a new dialog confirming that you want to publish and you have ensured following: "Do not publish confidential or proprietary information. If in doubt, check your organization's policies before publishing.". Well sounds reasonable. One should be careful about it, good part is, we used public data and properly referenced the sources above. The dialog is shown in Figure 15. Please move ahead.

Figure 13: Publish to Web Menu
Figure 14: Create embed code Dialog
Figure 15: Confirmation Dialog Before Publishing Report 
Creating the embed code will give you three information. One will be a link to share your report. Our report is available at Top Athlete Salaries 2014. Second, it will generate iframe code to embed report in online resources either its website, web-application or blog. Our report is shown embedded below:



Third information is the size of the iframe. You can adjust it using the combo box, but it can also be edited in your generate iframe code. For example, we change the width to 500 manually in generate embed code. Good, now its time to close down on this blog to avoid it from getting unreadable. Before we finish it up, this blog guides a new use to start working with Power BI using its desktop version. It only covered the Excel data and Table visualization.

I hope you enjoyed this tutorial explaining to beginners, How to start using Power BI Desktop for analytics. The next article in this series is Diving deep into data analytics with Power BI: Aggregate based Visualizations using MS Excel data.