exerCise 14-3. Creating MDx with the Cube browser
3. Verify that your results still match the results shown in Figure 14-36
in this exercise, you generated MDX code using the cube browser, copied the code to a new MDX code window, and reformatted and tested the code. while there is still much to learn about MDX, we hope you can now read and work with the code generated by the designer!
Moving On
At this point, you should be able to write and read basic MDX queries. While there is always more to learn, the good news is that most developers can work for many years in the BI field with the basic MDX knowledge covered in this chapter.
You may ask, “Then why should I learn this at all?” The answer is simple; MDX code created by applications is rarely the most efficient code to use. And sometimes the code generated by applications is incorrect for what you need to accomplish.
In addition, your MDX skills are a powerful tool for troubleshooting. Finally, you will need to use MDX expressions in many places throughout the SSAS management and development tools. While you will seldom use whole queries in these places, understating how MDX expressions work within an MDX query will help you create and troubleshoot there as well.
learn bY Doing
in this “Learn by Doing” exercise, you create several MDX queries using the northwind database. we included an outline of the steps to perform and an example of how the authors handled them in two word Figure 14-37. MDX code automatically generated by the cube browser
What Next?
Becoming good at writing MDX is not an easy task. At the time of this writing, few books and web pages exist for beginners to learn from. A web search will reveal a few, however. Here is one example:
Microsoft SQL Server 2008 MDX Step by Step MS Press
Bryan C. Smith and C. Ryan Clay ISBN-13: 978–0735626188
Chapter 15
Reporting with Microsoft Excel
When you’re working in front of an audience, you have incentive to excel.
—Dave Van Ronk Excel is Microsoft’s frontline reporting software. Starting originally as a commercial spreadsheet application, it has become much more.
Excel organizes data in a grid of rows and columns. These rows and columns can manipulate numeric type data by performing various calculations. Excel then is capable of displaying that data in different forms such as in charts, graphs, or other forms of reports. Excel even has a programming aspect that uses Visual Basic for Applications to perform tasks. This information can then be reported to the spreadsheet or used in other ways.
This range of capabilities allows programmers to perform advanced BI reporting, but it is not limited to professional developers. Excel reports are most commonly created by users with little to no programming skills, allowing nonprogrammers the ability to create quick and efficient ad hoc reports.
In this chapter, we discuss Microsoft Excel and how it is used to create personal and departmental BI reports.
We see how easy it is to create reports from your data warehouse and your cubes. And, we look at a simple way to distribute reports among co-workers using a .pdf file. Before we begin all that, let’s overview Microsoft’s reporting applications and see where Excel fits within the scheme of things.
Microsoft’s BI Reporting
Microsoft has spent a lot of money creating and improving BI reporting applications over the last several years. It now offers a great many reporting applications to choose from.
Table 15-1 gives an overview of some of the most current ones.
Table 15-1. BI Reporting Categories
Application Description Pros Cons
Excel 2010 The core spreadsheet application includes more reporting features than ever. Microsoft now considers this a vital part of its BI applications stack.
Easy to learn, and earlier, similar versions have been used for more than a decade.
Must be purchased and installed on all PCs and is designed to be a single- user application.
PowerPivot A free add-on to Excel 2010 and SharePoint 2010. It adds quite a number of advanced reporting features to both applications.
Easy to install and use. It allows for professional-looking ad hoc report building.
Must have Excel 2007 or 2010 installed on all PCs and is designed as a single- user application.
Visual Studio A professional development tool for creating server-based reports.
Provides full development tools for creating web-based reports.
Comparably steep learning curve similar to learning SSIS and SSAS.
Reporting Builder
A free application that is a simplified development tool for creating
Reporting Server reports.
Easy to install and use. Cannot do as much as Reporting Server’s full development tools.
SharePoint Allows users to share documents and develop custom applications and components for, among other things, reporting.
Anyone with a web browser can build and view reports from SharePoint.
Comparably high setup requirements.
Provides a comprehensive tool set for creating an organization’s internal web portal.
Comparably steep learning curve similar to learning SSIS and SSAS.
Performance Point
Discontinued as a stand-alone application and is now included in SharePoint 2010.
Adds a lot of advanced reporting features to SharePoint.
Comparably high setup requirements.
Anyone with a web browser can build and view reports from SharePoint.
(continued)
Most of these applications’ features overlap with each other, and it is likely that Microsoft will continue to combine them in the future. But, currently all of them may be considered valid options for BI reporting.
Digging through Microsoft’s documentation and web pages reveals that Microsoft has classified its reporting software into three basic categories: personal, departmental, and organizational. Figure 15-1 shows a breakdown of Microsoft’s most common BI reporting tools and which category they are associated with.
Application Description Pros Cons
Excel Services and Visio Services
Add-ons to SharePoint.
You can share Excel and Visio documents through a SharePoint server that can then be reviewed with a web browser.
Anyone with a web browser can see the reports from SharePoint.
Comparably high setup requirements.
Excel Services are available only on SharePoint Server 2010 Enterprise.
A complex way of sharing documents.
Power View Combines features from Excel, PowerPivot, Report Builder, Report Server, and SharePoint.
Allows for professional-looking ad hoc report building.
Comparably difficult setup requirements.
Anyone with a web browser can view reports from SharePoint.
Microsoft SharePoint Server 2010, SQL 2012 data engine, Reporting Services 2012, Power View add-in for Reporting Services, and PowerPivot add-in for SharePoint are all required for installation.
Table 15-1. Continued
Personal BI Departmental BI Organizational BI Excel
PowerPivot Report Builder
Power View
Excel PowerPivot Reporting Server
Report Builder SharePoint Power View
Reporting Server SharePoint Performance Point
Excel Services Visio Services
Figure 15-1. Mircrosoft’s BI reporting software categories
You can see that many applications overlap between the different categories. To give you a better understanding of each category, take a look Table 15-2.
Table 15-2. BI Reporting Categories
Category Description Pros Cons
Personal BI Software used to create ad hoc reports for individuals or small groups of users in a self-serve environment.
Often created by managers and leads for quick glimpses of current events.
Development time in hours.
Immediate access to reports.
Encourages data exploration and what-if scenarios.
Training required to create basic reports is in days.
Everyone creating and viewing these reports needs read access to the BI views, stored procedures, or cubes.
Conflicting reports are a common occurrence.
No standard look or feel, and reports are often very basic.
Often the person who creates the report is the only person who will use it.
Departmental BI Software used to create reports for small to midsize groups with a mix of self-served and delivered reports.
Development time of days.
Access to views, stored procedures, and cubes can be limited to only report developers and power users.
Conflicting reports are less common.
One report is used by many users.
Departmental look and feel builds confidence.
Reports tell a single story throughout the department.
Reports are often advanced.
Reports are not immediately available.
Requires at least peer testing and validation time.
Discourages data exploration and what-if scenarios.
Requires team members to dedicate some or all of their time to creating and maintaining reports.
Training required to create advanced reports can take weeks.
Organizational BI Software used to create reports used by multiple departments within an organization.
Access to views, stored procedures, and cubes can be limited to only report developers.
One report is used by many users.
Conflicting reports are rare.
Organizational look and feel builds confidence.
Reports tell a single story throughout the organization.
Reports can be made available outside of organization with confidence.
Reports are often interrelated and
Development time takes weeks.
Reports are not immediately available.
Requires a dedicated testing and validation team.
Discourages data exploration and what-if scenarios.
Requires a dedicated development team.
Training required to create very advanced reports takes months.
As you saw in Figure 15-1, Excel is situated as a tool for both personal and departmental BI solutions. Let’s get started learning how to use it!
Excel Reports from the Data Warehouse
Excel is capable of creating reports from many different data sources including text files and Microsoft Access database and web services, to name a few. Excel becomes even more powerful when you couple it with either Microsoft SQL Server or Microsoft’s Analysis Server. This coupling feature, which has been available to Excel since 1998, is one of the primary reasons for Excel’s prominence as a reporting tool.
A number of additional reporting features were included with Office 2007. Office 2010 was given even more features and is required for a number of the current BI add-ons, such as PowerPivot.
Creating a connection to either data warehouses or cubes is quite simple. We walk you through both options within this chapter. We begin with Microsoft SQL Server and the data warehouse you created in Chapter 5.
Creating a Connection
To create a connection to a data warehouse on Microsoft SQL Server, the first thing to do is open an existing Excel spreadsheet or create a new one. From the open spreadsheet, go to the Data tab on Microsoft’s Ribbon interface.
Locate the Get External Data button group and click From Other Sources to access an additional set of options (Figure 15-2).
Figure 15-2. Getting report data from an external source
Tip
■ The Ribbon interface exists in office 2007 and 2010. if you are not using one of those versions of office, you can still connect to sQl server or Analysis server using a very similar process. The major difference is that your environment will appear differently than it does in this chapter.
Please note that if your screen is small, the Get External Data button group may appear as a single button (Figure 15-2). If that is the case, click the single button for the collection of other buttons to become available.
Once the additional set of options is visible, select the From SQL Server option.
the MiCrosoft offiCe ribbon
we will be showing several screen shots in this chapter that include the Microsoft office Ribbon. The Ribbon dynamically changes as the window size is increased or decreased. This means that the Ribbon may look quite different between one screen shot and the next. for example, compare the two views of the Ribbon in figure 15-3. Both are of the same window. The difference is simply that the window size has been changed.
As you saw in Figure 15-2, a number of connection options are available. Once you select a connection option, Excel’s Data Connection Wizard begins the process of creating a connection file for you. This connection file stores both a connection string and a SQL command on your hard drive so that it can be reused in future
Figure 15-3. The Microsoft Office Ribbon changes appearance based on an application’s window size
The Data Connection Wizard
Once the Data Connection Wizard launches, it asks for the database server name (Figure 15-4).
Figure 15-4. Making a connection to your database server
Click Next, and you are given an option to select a table or view from the data warehouse to use for your report. Unfortunately, you cannot select more than one table, so the most obvious choice is to use a view that delivers data from multiple tables. In Chapter 13, we created a number of reporting queries, including one view called vQuantitiesByTitlesDate. As Figure 15-5 shows, we can select that from the list.
Important
■ All the code needed for the views demonstrated in this chapter can be found in the file ViewsAndStoredProceduresForChapter15.sql. simply open the file in sQl server Management studio, and execute the sQl code. Doing so allows you to follow along as we go through each example.
After you have selected the view and clicked Next, the wizard asks where you would like to save your connection file (Figure 15-6). The default name and settings is perfectly fine 99 percent of the time. But, if you would like to choose another location, you can click the Browse button and navigate to the new location.
Figure 15-5. Selecting objects from your SQL Server
Click Finish to create the file, close the Data Connection Wizard, and create a connection to the database.
What is an . odc file?
in figure 15-6, the connection file ends with an .odc extension, which indicates it is an oleDB data
connection file. An oleDb data connection (.odc) file contains a connection string and query information in an xMl format. figure 15-7 shows the contents of an .odc file.
Figure 15-7. The contents of an .odc file
Creating a Report
After the wizard closes, the Import Data dialog window appears. The Import Data dialog window allows you to select between a tabular report, a pivot table report, and a pivot chart + pivot table report (Figure 15-8). However, some options may not be available depending on what type of connection you created.
Figure 15-8. Selecting a PivotTable report
This dialog window also gives you an option to create a new worksheet and select the location of cells within an existing worksheet to create the report object. Because cells can be relocated, we leave the default setting and click OK to have Excel create the report.
When you choose a pivot table report, the final outcome after the connection wizard closes will look like Figure 15-9. We have seen this in earlier chapters, but now let’s look at it in more detail.
Note
■ notice the PivotTable field list area on the right side of Excel in figure 15-9. oddly, this disappears if you click away from the PivotTable. Each time we do a demo of this feature in class, someone shouts out, “Hey, where did it go?” Just click on the PivotTable once more to view it again.
Configuring a Report
When using a pivot table or chart, you need to identify the data from the data source to be included in your report. Report data can be selected by checking the checkbox in the pivot table field list or by dragging and dropping the field list items to the pivot table or chart, or to the designer areas below the field list.
As an example, in Figure 15-10 we have created a simple report by dragging the PublisherName and Title fields into the Row Labels designer area and the Total for that Date by Title field into the Values designer area.
Figure 15-9. An empty PivotTable report
In the next exercise, you get a chance to try it yourself.