The Microsoft MVP Award Program Blog

Independent Experts. Real World Answers.

The Microsoft MVP Award Program Blog

Independent Experts. Real World Answers.

Using Power Pivot and Power View for Profit Analysis

Using Power Pivot and Power View for Profit Analysis

  • Comments 4

Editor’s note: The following post was written by SharePoint MVP John White

Using Power Pivot and Power View for Profit Analysis

Power Pivot and Power View allow end users to quickly analyze corporate data without having to go through a complex data warehouse or cube design up front. In this article we will walk through the process of connecting to and analyzing corporate data. We will be working with the sample Fabrikam Great Plains database from Microsoft. The Fabrikam database ships with Great Plains, but if you want to work with it, and you don’t have GP, you can download it here.

In the past, it would have been necessary to import the data into Excel, use VLookups to establish relationships between the data, and then we would be able to use pivot tables and pivot charts to analyze it. We would also be subjected to the data size limitations in Excel (65,536 rows in 2003, over a million in 2007-2013). However, if we bring the data directly into the data model, we can circumvent these limitations, and with SharePoint, we can refresh the data automatically. There are 3 ways to do this – through the traditional data import mechanism, through Power Pivot’s data import feature, or through by using the new Power Query add-in. We’ll cover the first two here.

Getting the Data

Excel Data Import

Firstly, we can use the traditional means of Excel import via the Data tab, Other Sources and selecting SQL Server.

image

Once you select the server name, and authentication, things vary a little from what you may have been used to. Once you select your database, be sure to select the “Enable selection of multiple tables” option. You want to select this even if you will be working with a single table as this is the trigger that tells Excel to use the data model, instead of its own storage mechanism.

image

After creating a connection file, you will be prompted for how you want to import the data. Every option available will pull the requested data into the model, including the “Only Create Connection” option. The “Table” option will also pull the data into the worksheet, which in most cases you will not want, as you will be subject to the native Excel limits, and you’ll be storing the data twice.

It is possible to edit the connection, and build SQL queries that will help limit, sort, and transform the data, but a simpler method is to use Power Pivot’s data import feature.

Power Pivot Data import

Although Power Pivot is a part of Excel 2013, it isn’t turned on by default. If you don’t already see the Power Pivot tab, you can enable it by navigating to File – Options, and then selecting Add-Ins and selecting COM Add-ins from the drop down list, and clicking the Go button. Ensure that the “Microsoft Office PowerPivot for Excel 2013” add-in is selected.

image

Once enabled, you can click on the Power Pivot tab, and click Manage in the ribbon to open the Power Pivot editor. From there, start by selecting “Get External Data”, “From Database” and “From SQL Server”.

image

Here you enter in your connection information, and click Next. You may then choose to create your own Query, but we will choose the “Select from a list of tables…” option. Finally, you’ll be presented with a list of tables from the data source, in this case, Great Plains. We’re going to be doing a simple profit analysis, so we’re concerned with three tables:

Table

Purpose

Columns

RM00101

Customer Information

CUSTNMBR, CUSTNAME, ADDRESS1, COUNTRY , CITY, STATE, ZIP

SOP30200

Invoice Header Info

DOCDATE, SOPNUMBE,CUSTNMBR

SOP30300

Invoice Line Item Detail

SOPNUMBE, QUANTITY, UNITCOST, UNITPRICE

We’ll start with the main customer table. GP isn’t known for having intuitive table names, but right away Power Pivot start to help in this area. By specifying a Friendly Name, you make the data model much more approachable for end users. In this case, we name it “Customers”.

image

Using the Preview & Filter button, we can select precisely what data that we want to include in our model, making it much more efficient and less confusing to end users. Here you can see that we have selected CUSTNMBR and CUSTNAME – the other selected columns are off the screen.

image

From this screen you can also sort and filter the date from any column whether or not it is selected for inclusion, potentially making the model even more efficient. When complete, you are returned to the Table Import dialog. At any point in time, you can check your selections by clicking on the “Applied filters” link.

At this point, we can go ahead and repeat this process on the following two tables, naming SOP30200 “Headers” and SOP30300 “Line Items”, and selecting only the columns that we need. When complete, we click on Finish, and our data is imported.

image

The Fabrikam sample data set isn’t very large, but PowerPivot can literally handle hundreds of millions of rows of data, with almost no degradation of performance. However data load time is affected by volume. Once complete, you will be returned to the Power Pivot window.

image

Edit the Model

One of the first things that we want to do is to establish the relationships between the tables. The relationships in this case are straightforward, the Line Items table relates back to the Customers table via the Headers table using the SOPNUMBE and the CUSTNMBR columns respectively. The easiest way to do this is to use the diagram view, which can be found in the Home tab on the ribbon.

Once in the diagram view, simply drag the field to relate onto another field to relate. When done, the relationship should appear as follows. It should be noted that the arrows in the diagram do not point to the related fields, as in some other diagramming tools, they only indicate that there is a relationship between the tables.

image

Once the relationships are established, we can hide fields that we don’t plan on displaying to the end users. In this case we can hide all of the columns in the Line items table (we’ll add new columns shortly), and the SOPNUMBE and CUSTNMBR fields. We can do this by right clicking on the column, and selecting “Hide from Client tools”.

image

Once this is done, we can return to Data View to create some calculated columns and measures. First, we select the Line Items table. We’re doing a profit analysis, and ewe have unit price, unit cost, and quantity. The profit is the difference between the extended price and the extended cost, so the first thing that we want is the extended price. Click on the cell below the “Add Column” heading to the right of the last column of data. Type the “=” key on the keyboard, then with your mouse, click on the corresponding UNITPRCE cell. Then type the * key and click on the QUANTITY field, hit enter, and we have our unit price. Right click on the column header and select “Rename Column”. Rename the column to “Ext Price”.

Repeat this process for Extended Cost, Profit (Ext Price – Ext Cost) and finally Margin (Profit/Ext Cost), renaming each column accordingly.

The first three columns are in dollars, so our model should reflect that. Select all three columns, and in the ribbon, select Currency as the format. With the Margin column selected, select %.

image

Next, we want to always be working with the total profit, or the average profit, and we want to make it easy for the end users to do that. We therefore will create a calculated measure by selecting a cell immediately below the data in the Profit column. Then, click on the AutoSum dropdown from the ribbon, and select Sum. Click on the function bar to change the name from Sum of Profit to Total Profit.

Next, select the cell below that, and repeat the process, but select Average this time, and rename it to “Average Profit”. Finally, since we’ll only be working with the calculated measures, select the Ext Price, Ext Cost, and Profit columns, and hide them from client tools.

image

Next, we want to modify the Customers table a bit, so first we select it. Next, rename the columns to be more business friendly. Click on the Country column, and select the Advanced tab. The Data Category for Country is Country/Region. This is because the model recognized that this field represented Country values, and flagged it accordingly. It doesn’t always get this right, and a quick inspection should reveal that this has not happened for Address and State. Use the dropdown to flag them as Address and “State or Province” respectively.

image

We are now ready for our simple Power View report.

Analysis

Select your blank Excel workbook, click on the Insert tab and select Power View. After a moment, the Power View design surface will open. From the “Power View Fields” pane, open up Customers, and select Country, then open up Line Items and select Total Profit. The Globe field beside Country indicates that it is geo-locatable, and the calculator beside Total profit indicates that it is a calculated measure.

You will notice a small table has appeared on the design surface showing Country and Profit. Increase the size of the table by grabbing one of the corner handles and dragging. Make it the width of the design surface, and a little more than half the height.

image

Finally, from the ribbon, click on Map. You will see that the data is represented geographically on a map. Now, with the map still selected, drag the state and city fields down under Country in the Locations box. Now try double clicking on one of the countries, and then on one of the states. The map will drill down to the next level. To drill up, click the little “up” icon on the upper right of the map.

image

Next, click in an unused area of the design surface. This time, select Name (from Customers) and Total Profit (from Line Items). Click twice on the Total Profit header to sort the data from largest to smallest, and resize it so that it fills the width of the design surface. Finally, from the Design ribbon, Select Column Chart – Stacked Column.

image

Click on one of the data columns and observe the effect on the map. Next, do the reverse, drill down to a state, click on a state and notice how the column chart is updated. Everything in Power Pivot is cross filtered, allowing you to very quickly discover facts about your data.

Sharing

SharePoint supports embedded data models through Excel Services along with Power Pivot for SharePoint. This means that a power user can upload a workbook to a SharePoint library, and a user with a browser can work with it. Power Pivot for SharePoint (on premises) can also schedule automatic refreshes of the data on a scheduled basis. Office 365 also supports embedded data models, although for the moment, it can’t automatically refresh them. Power BI will address this in the near future.

To share the model with other Office 365 users, simply upload it to an online document library. Once uploaded, open it with a browser, and you will be presented with your Power View report.

image

Summary

Historically, implementing and using Business Intelligence products could be a cumbersome and daunting process. As we’ve seen here, with Power Pivot and Power View, it’s possible to very quickly get answers from corporate data. Traditional data warehouses and cubes still have their place, and can be well utilized by these new tools, but we no longer need to wait for their complete implementation to be able to realize the benefits of these Business Intelligence tools.

About the author

jpwHeadshotSquareFull

John P White is the Chief Technical Officer at UnlimitedViz Inc. He holds a Master’s degree in Engineering from the University of Guelph and is a Microsoft SharePoint MVP. He has spent 22 years in the Information Technology space, and possesses a skill set that spans both architecture and development. He has been instrumental in delivering projects and applications that have been recognized with both local and global awards from Microsoft and IBM.

As a seasoned IT professional, John has accumulated a plethora of legacy technologies like Novell, Lotus Notes and Java. This experience has proven invaluable when architecting systems alongside legacy applications. Over the past decade, he has been focused on the Microsoft SharePoint and Business Intelligence platforms and has become an expert with the latest that these platforms have to offer.

He is a frequent speaker at user groups and conferences, and he blogs as actively as possible at http://whitepages.unlimitedviz.com. John lives in Guelph, Ontario, and is the father of 3 boys, is an avid scuba diver, and a budding photographer, both under and above the water. Samples of his work can be found at http://www.flickr.com/wpages. Follow him on Twitter.

About MVP Mondays

The MVP Monday Series is created by Melissa Travers. In this series we work to provide readers with a guest post from an MVP every Monday. Melissa is a Community Program Manager, formerly known as MVP Lead, for Messaging and Collaboration (Exchange, Lync, Office 365 and SharePoint) and Microsoft Dynamics in the US. She began her career at Microsoft as an Exchange Support Engineer and has been working with the technical community in some capacity for almost a decade. In her spare time she enjoys going to the gym, shopping for handbags, watching period and fantasy dramas, and spending time with her children and miniature Dachshund. Melissa lives in North Carolina and works out of the Microsoft Charlotte office.

  • Nice

  • Instead of using AVERAGE in the calculated field, it would be probably better using SUM([Profit]) / SUM( [Ext Cost]), so you have a weighted average instead of a simple one.

  • Marco - You are quite correct - and it's much more efficient as well. I approached it this way to make it as simple as possible for demonstration, but absolutely - don't do it like this in production!

  • Hey John,

    Great post..

    I seems as if you attachment to the downloadable example has disappeared

    Any ideas?

    Jeremy

Page 1 of 1 (4 items)
Leave a Comment
  • Please add 5 and 4 and type the answer here:
  • Post