34
Introduction to Power Query David Dye

IntroductionToPowerQuery

Embed Size (px)

DESCRIPTION

PQ

Citation preview

Page 1: IntroductionToPowerQuery

Introduction to Power Query David Dye

Page 2: IntroductionToPowerQuery

Introduction to Power Query • Introduction • Introduction to Power Query • Working With Power Query

Page 3: IntroductionToPowerQuery

Introduction • David Dye

[email protected] • HTTP://WWW.SQLSAFETY.COM

Page 4: IntroductionToPowerQuery

Introduction to Power Query

Page 5: IntroductionToPowerQuery

What is Power Query? • Excel add in

– Available in Excel 2013 and 2010 Professional Plus • Provides a means natively in Excel to:

– Discovering – Combining – Refining data – Merge and shape data across multiple sources – Create custom views over data – Perform data cleansing operations

• Allows access to a wide variety of data sources • The ETL tool for Excel

Page 6: IntroductionToPowerQuery

What is the Difference Between Power Query and PowerPivot

• Power Query can – Pull data from sources not readily available in PowerPivot

• Facebook • Hadoop • MySQL

– Inline Transformations • Provides a “Steps” view to recap transformations

– Append and Merge can take tables from different sources and present them as one

– Supports JSON when working with Web API’s

Page 7: IntroductionToPowerQuery

Working with Power Query

Page 8: IntroductionToPowerQuery

Insuring Power Query is Enabled • If Power Query is not available in the menu bar make sure

that is enabled

– Files>Options> Add-Ins Manage COM Add-Ins

• Power Query can be downloaded from http://www.microsoft.com/en-us/download/details.aspx?id=39379

Page 9: IntroductionToPowerQuery

Demonstration 1 Enable Power Query

Page 10: IntroductionToPowerQuery

Working with Power Query • Once installed the Power Query menu is

available • Provides the tools to create the data models

or sheets based on the data sources

Page 11: IntroductionToPowerQuery

Demonstration 2 Opening Power Query

Page 12: IntroductionToPowerQuery

Power Query Data Sources – Web page – Excel or CSV file – XML file – Text file – Folder – SQL Server database – Windows Azure SQL Database – Access database – Oracle database – IBM DB2 database – MySQL database – SharePoint List – OData feed – Hadoop Distributed File System (HDFS – Windows Azure Marketplace – Active Directory – Facebook

Page 13: IntroductionToPowerQuery

Data Sources From Web • Online Search

– Searches different sources on the internet, extranet, and intranet • Integrates with Office 365 as part of Power BI

• From Web – Enter Url of data source location

• From Other Sources – SharePoint list – OData Feed – Windows Azure Marketplace – Facebook

Page 14: IntroductionToPowerQuery

Demonstration 3 Online search Web source Facebook source

Page 15: IntroductionToPowerQuery

Importing Data • From the Power Query Menu

– Select the data source

Page 16: IntroductionToPowerQuery

Importing Data Cont. • Depending on the source additional

configuration will be necessary

Page 17: IntroductionToPowerQuery

Query Editor

Page 18: IntroductionToPowerQuery

Filtering Data • A filter can be applied to query results limiting

the rows – This will filter the rows that will be saved in Excel

or within a data model

Page 19: IntroductionToPowerQuery

Filtering Data Cont. • Columns can be removed from the result set

of the query to help shape your data

Page 20: IntroductionToPowerQuery

Query Properties • There are several properties that can be

configured from the Query Editor > View tab – The Query Settings button will show or hide the Query

settings tab – The Advanced Editor opens a modal window that will

show the Power Query formula for the query – The Formula bar check box will display the formula

bar when checked

Page 21: IntroductionToPowerQuery

Working With Query Results • There are a number of built in functions in the Query Editor

window that allows you to transform your data – Remove TOP N Rows

• Removes the top number of rows specified – Remove Columns

• Removes the column(s) selected – Sort – Replace values – Remove duplicates will remove duplicate rows from the query

result set

Page 22: IntroductionToPowerQuery

Group By • Allows you to apply a grouping and

aggregation on query results – Retains the original query results

Page 23: IntroductionToPowerQuery

Group By Cont.

Page 24: IntroductionToPowerQuery

Split • Provides the ability to split a single column into two or more columns • Several configuration options that allow for simple to complex parsing • Retains the original query results

Page 25: IntroductionToPowerQuery

Split Cont.

Page 26: IntroductionToPowerQuery

Merge • Allows you to combine different query results

– Acts like a SQL JOIN – Define the column(s) to match – Select whether to show non matching results

Page 27: IntroductionToPowerQuery

Append • Allows you to merge result sets from separate queries

together • Unlike a Merge all results are returned and you do not need

to specify a column on which to match

Page 28: IntroductionToPowerQuery

Demonstration 4 SQL Source and filtering Group By Split Append Merge

Page 29: IntroductionToPowerQuery

Power Query Formula • Power Query has its own formulas

– Informally known as “M” – More powerful than Excel – Only available from within Power Query – Full documentation and syntax can be found here

• http://office.microsoft.com/en-us/excel-help/learn-about-power-query-formulas-HA104003958.aspx

Page 30: IntroductionToPowerQuery

Demonstration 5 Create a calculated column Table Compare

Page 31: IntroductionToPowerQuery

What’s This All For??? • Power Query acts as the ETL tool providing the

ability to work with data across numerous formats and locations

• All results are opened in Excel as a pivot table • Refreshing the data will refresh the results

Page 32: IntroductionToPowerQuery

Save As A Data Model • Results are always opened in Excel as a pivot

table, but can also be saved as a data model • An Excel Data Model is a relational data source

composed from multiple tables inside an Excel workbook

• Within Excel, a Data Model is used transparently, providing tabular data used in PivotTables, PivotCharts, and Power View reports.

Page 33: IntroductionToPowerQuery

What’s Next?? • Extracting or conglomerating the data in Excel

is the first step • Working with the data natively in Excel is one

option • PowerPivot allows you to create complex

tabular data models and extends the capabilities of Excel

Page 34: IntroductionToPowerQuery

Demonstration 6 PowerPivot