23
SQL Server 2014 BI Lab 06 Creating an Excel Report Based on a Tabular Data Model in SQL Server 2014 Jump to the Lab Overview

Creating an Excel Report Based on a Tabular Data Model in SQL Server · PDF file · 2014-11-20Model in SQL Server 2014 Jump to the Lab Overview . Page 2 ... and the Monitoring and

  • Upload
    ngodien

  • View
    213

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Creating an Excel Report Based on a Tabular Data Model in SQL Server · PDF file · 2014-11-20Model in SQL Server 2014 Jump to the Lab Overview . Page 2 ... and the Monitoring and

SQL Server 2014 BI

►Lab 06

Creating an Excel Report

Based on a Tabular Data

Model in SQL Server 2014

Jump to the Lab Overview

Page 2: Creating an Excel Report Based on a Tabular Data Model in SQL Server · PDF file · 2014-11-20Model in SQL Server 2014 Jump to the Lab Overview . Page 2 ... and the Monitoring and

Page 2

© Copyright 2014 Microsoft Corporation. All rights reserved.

Terms of Use

© 2014 Microsoft Corporation. All rights reserved.

Information in this document, including URL and other Internet Web site references, is subject to change

without notice. Unless otherwise noted, the companies, organizations, products, domain names, e-mail

addresses, logos, people, places, and events depicted herein are fictitious, and no association with any real

company, organization, product, domain name, e-mail address, logo, person, place, or event is intended

or should be inferred. Complying with all applicable copyright laws is the responsibility of the user.

Without limiting the rights under copyright, no part of this document may be reproduced, stored in or

introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical,

photocopying, recording, or otherwise), or for any purpose, without the express written permission of

Microsoft Corporation.

For more information, see Microsoft Copyright Permissions at http://www.microsoft.com/permission

Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property

rights covering subject matter in this document. Except as expressly provided in any written license

agreement from Microsoft, the furnishing of this document does not give you any license to these

patents, trademarks, copyrights, or other intellectual property.

The Microsoft company name and Microsoft products mentioned herein may be either registered

trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. The

names of actual companies and products mentioned herein may be the trademarks of their respective

owners.

This document reflects current views and assumptions as of the date of development and is subject

to change. Actual and future results and trends may differ materially from any forward-looking

statements. Microsoft assumes no responsibility for errors or omissions in the materials.

THIS DOCUMENT IS FOR INFORMATIONAL AND TRAINING PURPOSES ONLY AND IS PROVIDED

"AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING BUT

NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR

PURPOSE, AND NON-INFRINGEMENT.

Page 3: Creating an Excel Report Based on a Tabular Data Model in SQL Server · PDF file · 2014-11-20Model in SQL Server 2014 Jump to the Lab Overview . Page 2 ... and the Monitoring and

Page 3

© Copyright 2014 Microsoft Corporation. All rights reserved.

Contents

TERMS OF USE ............................................................................................................................... 2

CONTENTS ..................................................................................................................................... 3

ABOUT THE AUTHOR .................................................................................................................... 4

DOCUMENT REVISIONS ................................................................................................................ 4

LAB OVERVIEW .............................................................................................................................. 5

EXERCISE 1: CREATING THE COUNTRY SALES REPORT ............................................................ 6

Task 1 – Preparing the Excel Workbook ............................................................................................................................ 6

Task 2 – Creating the Workbook Connection and PivotTable ................................................................................. 8

Task 3 – Defining the PivotTable Layout ........................................................................................................................... 9

Task 4 – Defining a Dynamic Date Filter ........................................................................................................................ 11

Task 5 – Filtering with a Slicer ............................................................................................................................................ 13

Task 6 – Inserting a Sparkline ............................................................................................................................................. 15

Task 7 – Formatting the Report ......................................................................................................................................... 17

Task 8 – Inserting a Bar Chart ............................................................................................................................................. 19

Task 9 – Finalizing the Report Layout ............................................................................................................................. 20

EXERCISE 2: PUBLISHING THE COUNTRY SALES REPORT ....................................................... 21

Task 1 – Configuring the Browser View Options ........................................................................................................ 21

Task 2 – Publishing the Workbook to SharePoint ...................................................................................................... 21

Task 3 – Reviewing the Published Workbook .............................................................................................................. 22

Task 4 – Finishing Up ............................................................................................................................................................. 23

SUMMARY .................................................................................................................................... 23

Page 4: Creating an Excel Report Based on a Tabular Data Model in SQL Server · PDF file · 2014-11-20Model in SQL Server 2014 Jump to the Lab Overview . Page 2 ... and the Monitoring and

Page 4

© Copyright 2014 Microsoft Corporation. All rights reserved.

About the Author

This lab was designed and written by Peter Myers.

Peter Myers has worked with Microsoft database and development products since

1997. Today, he specializes in all Microsoft BI products and provides mentoring,

technical training, and education content authoring for SQL Server, Office, and

SharePoint. Peter has a broad business background supported by a bachelor’s

degree in applied economics and accounting, and he extends this with solid experience backed

by current MCSE and MCT certifications. He has been a SQL Server MVP since 2007.

Document Revisions

# Date Author Comments

0 19-OCT-2014 Peter Myers Initial release

Page 5: Creating an Excel Report Based on a Tabular Data Model in SQL Server · PDF file · 2014-11-20Model in SQL Server 2014 Jump to the Lab Overview . Page 2 ... and the Monitoring and

Page 5

© Copyright 2014 Microsoft Corporation. All rights reserved.

Lab Overview

Introduction

In this lab, you will create a report in Excel 2013 based on a corporate tabular data model. You

will then publish the workbook to an on-premises SharePoint site, and then explore the report

rendered by Excel Services in the web browser.

Objectives

The objectives of this exercise are to:

Create an Excel Report based on a tabular BI Semantic Model

Work with PivotTables

Work with the Excel CUBE functions

Work with slicers, sparklines and charts

Publish an Excel Workbook to SharePoint Server

Interact with the published workbook in the web browser

Exercises

This hands-on lab comprises the following exercise:

1. Creating the Country Sales Report

2. Publish the Country Sales Report

Estimated time to complete this lab: 30 minutes

Page 6: Creating an Excel Report Based on a Tabular Data Model in SQL Server · PDF file · 2014-11-20Model in SQL Server 2014 Jump to the Lab Overview . Page 2 ... and the Monitoring and

Page 6

© Copyright 2014 Microsoft Corporation. All rights reserved.

Exercise 1: Creating the Country Sales Report

In this exercise, you will create a report in Excel 2013 based on a tabular BI Semantic Model. You

will commence by creating a PivotTable based on the AW Sales database. Then you will convert

the PivotTable to formulas and customize the layout with a slicer, a sparkline and a bar chart.

The finished report will look like the following.

Figure 1

Previewing the Country Sales Report

Task 1 – Preparing the Excel Workbook

In this task, you will create a new workbook and prepare it for the report design.

1. To open Excel, on the taskbar, click the Excel shortcut.

Figure 2

Selecting the Excel Shortcut

Page 7: Creating an Excel Report Based on a Tabular Data Model in SQL Server · PDF file · 2014-11-20Model in SQL Server 2014 Jump to the Lab Overview . Page 2 ... and the Monitoring and

Page 7

© Copyright 2014 Microsoft Corporation. All rights reserved.

2. To create a blank workbook, in the templates pane, click Blank Workbook.

3. Right-click worksheet tab Sheet1, and then select Rename.

4. Rename the worksheet to Country Sales, and then press Enter.

5. In cell A1, enter the text Country Sales.

6. Ensure cell A1 is selected, and the on the Home ribbon tab, inside the Font group,

increase the font size to 20pt.

7. On the File ribbon, click Save As.

8. Click Browse.

9. In the Save As window, navigate to the D:\SQLServerBI\Lab06 folder.

10. In the File Name box, replace the text with Country Sales, and then click Save.

Page 8: Creating an Excel Report Based on a Tabular Data Model in SQL Server · PDF file · 2014-11-20Model in SQL Server 2014 Jump to the Lab Overview . Page 2 ... and the Monitoring and

Page 8

© Copyright 2014 Microsoft Corporation. All rights reserved.

Task 2 – Creating the Workbook Connection and PivotTable

In this task, you will define a workbook connection to the AW Sales database, and create a

PivotTable based on the connection.

1. Select cell B4.

2. On the Data ribbon tab, from inside the Get External Data group, click From Other

Sources, and then select From Analysis Services.

Figure 3

Getting Data From Analysis Services

3. In the Data Connection Wizard, at the Connect to Database Server step, in the Server

Name box, enter localhost\TABULAR, and then click Next.

4. At the Select Database and Table step, in the dropdown list, ensure the AW Sales

database is selected.

5. Notice that the database contains three cubes/tables. The Model cube is the default

perspective, and the Monitoring and Sales cubes are explicit perspectives of the model.

6. Ensure Model is selected, and then click Next.

7. At the Save Data Connection File and Finish step, in the Friendly Name box, modify

the text to AW Sales.

Page 9: Creating an Excel Report Based on a Tabular Data Model in SQL Server · PDF file · 2014-11-20Model in SQL Server 2014 Jump to the Lab Overview . Page 2 ... and the Monitoring and

Page 9

© Copyright 2014 Microsoft Corporation. All rights reserved.

8. Click Finish.

9. In the Import Data window, in the Existing Worksheet box, replace the value with $B$4,

and then click OK.

Task 3 – Defining the PivotTable Layout

In this task, you will define the PivotTable layout to display sales by the quarters for calendar

year 2013, and by country. You will then convert the PivotTable to formulas so that the layout

can be customized beyond what can be achieved with a PivotTable.

1. In the PivotTable Fields (located at the right), in the ResellerSales measure group,

check the Sales measure.

2. Notice that the measure is added to the Values drop zone, and that the PivotTable

displays the aggregate of all sales.

3. From the Date dimension, drag the Calendar hierarchy into the Columns drop zone.

Figure 4

Adding the Calendar Hierarchy to the Columns Drop Zone

4. To keep only the CY2013 member, right-click the CY2013 member (cell E5), and then

select Filter | Keep Only Selected Items.

Page 10: Creating an Excel Report Based on a Tabular Data Model in SQL Server · PDF file · 2014-11-20Model in SQL Server 2014 Jump to the Lab Overview . Page 2 ... and the Monitoring and

Page 10

© Copyright 2014 Microsoft Corporation. All rights reserved.

5. To expand to the quarter level, expand the CY2013 member (cell C5).

6. To remove the year level, right-click the CY2013 member (cell C5), and then select

Show/Hide Fields | Year.

7. In the Reseller dimension, select the Geography hierarchy.

8. Notice that the Geography hierarchy is automatically added to the Rows drop zone.

9. Verify that the PivotTable looks like the following.

Figure 5

Verifying the PivotTable Layout

10. To convert the PivotTable to CUBE functions, on the PivotTable Tools Analyze

contextual ribbon tab, inside the Calculations group, click OLAP Tools, and then select

Convert to Formulas.

11. To explore the formulas based on the CUBE functions, select cell B4, and notice the

CUBEMEMBER function uses the AW Sales workbook connection, and retrieves the

Sales measure.

12. Select cell C5, and notice that the CUBEMEMBER function retrieves the member

representing the first calendar quarter of 2013.

13. Select cell G5, and notice that the CUBESET function retrieves a set of members

representing the four quarters, and displays the label Grand Total.

14. Select cell B6, and notice that the CUBEMEMBER function retrieves the member

representing the country Australia.

15. Finally, select cell C6, and position the cursor in the formula bar (as if to edit the

formula). Notice that that CUBEVALUE function retrieves a value at the intersection of

the three members highlighted in the worksheet (cells B4, B6 and C5).

Page 11: Creating an Excel Report Based on a Tabular Data Model in SQL Server · PDF file · 2014-11-20Model in SQL Server 2014 Jump to the Lab Overview . Page 2 ... and the Monitoring and

Page 11

© Copyright 2014 Microsoft Corporation. All rights reserved.

Task 4 – Defining a Dynamic Date Filter

In this task, you will modify the four CUBEMEMBER functions that retrieve the calendar quarter

members to reference a calendar year filter value entered by the user.

1. To introduce a calendar year filter, in cell B2 enter the text Calendar Year.

2. In cell C2, enter the text 2013.

3. To create a named range, ensure cell C2 is selected, and then on the Formulas ribbon

tab, inside the Defined Names group, click Define Name.

4. In the New Name window, in the Name box, replace the text with Year.

Figure 6

Defining a Name

5. Click OK.

6. To hide row 4, right-click the row guide, and then select Hide.

7. In cell B5, replace the text with Country.

8. In cell C5, modify the formula to dynamically reference the member based on the

calendar year value entered in cell C2. The expression will look like the following.

Note: The expressions required in the following steps may be copied from the

D:\SQLServerBI\Lab06\Assets\Snippets.txt file.

Excel

=CUBEMEMBER("AW Sales", "[Date].[Calendar].[Quarter].[CY" & Year & " Q1]")

Page 12: Creating an Excel Report Based on a Tabular Data Model in SQL Server · PDF file · 2014-11-20Model in SQL Server 2014 Jump to the Lab Overview . Page 2 ... and the Monitoring and

Page 12

© Copyright 2014 Microsoft Corporation. All rights reserved.

9. Repeat the last step to modify the formula in the three cells D5, E5 and F5.

10. To modify the width of all value columns, select the column C header, and then while

pressing the Shift key, select the column G header.

11. Right-click inside the selected range, and then select Column Width.

12. In the Column Width window, enter 13, and then click OK.

13. To format the values in report, select the range C6:G12, right-click inside the selected

range, and then select Format Cells.

14. In the Format Cells window, in the Category list, select Number.

15. In the Decimal Places control, reduce the number to 0 (zero).

16. Check the Use 1000 Separator checkbox.

Figure 7

Formatting the Cells

17. Click OK.

18. To test the calendar year filter, in cell C2, modify the value to 2012, and then press

Enter.

19. Notice that the values in the report automatically refresh according to the new filter

context.

20. In cell C2, modify the value back to 2013.

Page 13: Creating an Excel Report Based on a Tabular Data Model in SQL Server · PDF file · 2014-11-20Model in SQL Server 2014 Jump to the Lab Overview . Page 2 ... and the Monitoring and

Page 13

© Copyright 2014 Microsoft Corporation. All rights reserved.

Task 5 – Filtering with a Slicer

In this task, you will add a slicer to the worksheet to allow users to filter by the product

categories.

1. To accommodate the slicer, right-click the column A header, and then select Column

Width.

2. In the Column Width window, enter 30, and then click OK.

3. To insert a slicer, on the Insert ribbon tab, from inside the Filters group, click Slicer.

4. In the Existing Connections window, select the AW Sales workbook connection, and

then click Open.

5. In the Insert Slicers window, in the Product dimension, in the Products hierarchy, check

the Category level.

Figure 8

Inserting the Slicer

6. Click OK.

7. Move the slicer so that the top of the slicer is positioned in cell A2.

8. Right-click the slicer, and then select Slicer Settings.

Page 14: Creating an Excel Report Based on a Tabular Data Model in SQL Server · PDF file · 2014-11-20Model in SQL Server 2014 Jump to the Lab Overview . Page 2 ... and the Monitoring and

Page 14

© Copyright 2014 Microsoft Corporation. All rights reserved.

9. In the Slicer Settings window, notice the Name to Use in Formulas. You will use this

name to modify the CUBEVALUE functions in the report.

Figure 9

Reviewing the Slicer Settings

10. Click Cancel.

11. To update the report to filter by the slicer selection, select cell C6.

12. Modify the formula to include the reference the slicer. The expression will look like the

following.

Excel

=CUBEVALUE("AW Sales", $B$4, $B6, C$5, Slicer_Products)

13. To copy the new formula to the other value cells on the same row, ensure that cell C6 is

selected, and then drag the bottom right corner of the cell border to copy the formula

across to cell G6.

Figure 10

Copying the Formula to the Cells on the Same Row

Page 15: Creating an Excel Report Based on a Tabular Data Model in SQL Server · PDF file · 2014-11-20Model in SQL Server 2014 Jump to the Lab Overview . Page 2 ... and the Monitoring and

Page 15

© Copyright 2014 Microsoft Corporation. All rights reserved.

14. To copy the selected formulas to the remaining value cells on the rows beneath, drag

the bottom right corner of the bordered range, and then drag down to row 12.

Figure 11

Copying the Formula to the Cells on the Rows Beneath

15. To test the slicer, in the Category slicer, select the Bikes member.

16. Notice that the values in the report automatically refresh according to the new filter

context.

17. To clear the slicer filter, inside the slicer, click Clear Filter.

Figure 12

Clearing the Slicer Filter

Task 6 – Inserting a Sparkline

In this task, you will add a sparkline to provide trend information across the quarters for each

country.

1. To insert a new column, right-click the column G header, and then select Insert.

2. In cell G5, enter the text Trend.

3. Select cell G6.

Page 16: Creating an Excel Report Based on a Tabular Data Model in SQL Server · PDF file · 2014-11-20Model in SQL Server 2014 Jump to the Lab Overview . Page 2 ... and the Monitoring and

Page 16

© Copyright 2014 Microsoft Corporation. All rights reserved.

4. On the Insert ribbon tab, from inside the Sparklines group, click Line.

Figure 13

Locating the Line Sparkline

5. In the Create Sparklines window, in the Data Range box, enter C6:F6 (representing the

four quarters for that country).

Figure 14

Defining the Data Range

6. Click OK.

7. To copy the selected sparkline to the remaining cells on the rows beneath, ensure cell

G6 is selected, and then drag the bottom right corner of the bordered range down to

row 12.

Figure 15

Copying the Sparkline

Page 17: Creating an Excel Report Based on a Tabular Data Model in SQL Server · PDF file · 2014-11-20Model in SQL Server 2014 Jump to the Lab Overview . Page 2 ... and the Monitoring and

Page 17

© Copyright 2014 Microsoft Corporation. All rights reserved.

Task 7 – Formatting the Report

In this task, you will format the report.

1. Select the range B2:C2.

2. On the Home ribbon tab, from inside the Font group, click Bold.

3. Click the down arrow next to the Fill Color button, and then select a light blue color.

Figure 16

Selecting a Light Blue Fill Color

4. To copy the format from cell B2, select cell B2, and then on the Home ribbon tab, click

the Format Painter button.

Figure 17

Locating the Format Painter Button

5. To apply the format, select the range B5:H5.

6. Select the range C5:H5.

7. On the Home ribbon tab, from inside the Alignment group, click Align Text Right.

8. Select the range B12:H12.

Page 18: Creating an Excel Report Based on a Tabular Data Model in SQL Server · PDF file · 2014-11-20Model in SQL Server 2014 Jump to the Lab Overview . Page 2 ... and the Monitoring and

Page 18

© Copyright 2014 Microsoft Corporation. All rights reserved.

9. On the Home ribbon tab, from inside the Font group, click Bold, and then click the

down arrow next to the Borders button, and select Top and Double Bottom Border.

Figure 18

Formatting the Borders

10. Verify that the report layout looks like the following.

Figure 19

Reviewing the Report Layout

Page 19: Creating an Excel Report Based on a Tabular Data Model in SQL Server · PDF file · 2014-11-20Model in SQL Server 2014 Jump to the Lab Overview . Page 2 ... and the Monitoring and

Page 19

© Copyright 2014 Microsoft Corporation. All rights reserved.

Task 8 – Inserting a Bar Chart

In this task, you will insert a bar chart based to graphically represent sales by quarter for each

county.

1. Select the range B5:F11.

2. On the Insert ribbon tab, from inside the Charts group, click Column, and then select

the first 2-D Column chart type.

Figure 20

Selecting the Chart Type

3. Move the chart so that its top left corner sits in cell B14.

4. Drag the right border of the chart so that it fills the columns B:H (so it is the same width

as the table).

5. To remove the chart title, right-click Chart Title, and then select Delete.

Page 20: Creating an Excel Report Based on a Tabular Data Model in SQL Server · PDF file · 2014-11-20Model in SQL Server 2014 Jump to the Lab Overview . Page 2 ... and the Monitoring and

Page 20

© Copyright 2014 Microsoft Corporation. All rights reserved.

Task 9 – Finalizing the Report Layout

In this task, you will finalize the report layout in preparation for publishing.

1. To set the default cell selection, select cell C2.

2. On the View ribbon tab, from inside the Show group, uncheck Gridlines and uncheck

Headings.

Figure 21

Modifying the Show Properties

3. On the File ribbon tab (backstage view), click Save.

4. Verify that the report looks like the following.

Figure 22

Reviewing the Country Sales Report

Page 21: Creating an Excel Report Based on a Tabular Data Model in SQL Server · PDF file · 2014-11-20Model in SQL Server 2014 Jump to the Lab Overview . Page 2 ... and the Monitoring and

Page 21

© Copyright 2014 Microsoft Corporation. All rights reserved.

Exercise 2: Publishing the Country Sales Report

In this exercise, you will publish the Country Sales Report and explore the report rendered by

Excel Services in the web browser.

Task 1 – Configuring the Browser View Options

In this task, you will prepare the workbook for publication by setting the browser view options.

You will then publish the workbook to a SharePoint PowerPivot Gallery.

1. On the File ribbon tab, click Browser View Options.

Figure 23

Locating the Browser View Options Command

2. In the Browser View Options window, select the Parameters tab.

3. To add a parameter, click Add.

4. In the Add Parameters window, check Year, and then click OK.

Note: Slicers can also be added as parameters. This is not a requirement in this lab.

5. In the Browser View Options window, click OK.

6. To save the workbook, on the File ribbon Save.

Task 2 – Publishing the Workbook to SharePoint

In this task, you will upload a workbook to SharePoint.

1. On the File ribbon tab, select Save As.

2. Click Browse.

3. In the Save As window, in the File Name box, enter http://localhost and then press

Enter.

Page 22: Creating an Excel Report Based on a Tabular Data Model in SQL Server · PDF file · 2014-11-20Model in SQL Server 2014 Jump to the Lab Overview . Page 2 ... and the Monitoring and

Page 22

© Copyright 2014 Microsoft Corporation. All rights reserved.

4. When the AdventureWorks BI SharePoint site document libraries list returns, scroll

down, and then double-click PowerPivot Gallery.

5. In the File Name box, replace the text with Country Sales.

6. Click Save.

Task 3 – Reviewing the Published Workbook

In this task, you will interact with the published workbook in the web browser.

1. To open Internet Explorer, on the taskbar, click the Internet Explorer shortcut.

Figure 24

Selecting the Internet Explorer Shortcut

2. In the Internet Explorer favorites, select AdventureWorks BI Site.

3. In the Quick Launch (located at the left), select the PowerPivot Gallery library.

Figure 25

Selecting the PowerPivot Gallery Library

4. To render the report, click the Country Sales report preview.

5. In the Parameters pane (located at the right), in the Year box, enter 2012, and then click

Apply (located at the bottom of the pane).

Page 23: Creating an Excel Report Based on a Tabular Data Model in SQL Server · PDF file · 2014-11-20Model in SQL Server 2014 Jump to the Lab Overview . Page 2 ... and the Monitoring and

Page 23

© Copyright 2014 Microsoft Corporation. All rights reserved.

6. To hide the Parameters pane, click the arrow located in the pane’s top right corner.

Figure 26

Hiding the Parameters Pane

7. In the Category slicer, select the Bikes member.

8. While pressing the Control key, select the Components members.,

Task 4 – Finishing Up

In this task, you will finish up by closing all applications.

1. Close the Internet Explorer window.

2. To close Excel, click the X button located at the top right corner.

Summary

In this lab, you created a report in Excel 2013 based on a tabular BI Semantic Model. You then

published the workbook to SharePoint Server and explored the report rendered by Excel

Services in the web browser.