Sunteți pe pagina 1din 45

Top 5 Power Query M

Functions that You


Don’t Know
Reza Rad, DW/BI Architect and BID-309
Consultant
RADACAD
Please silence
cell phones
Explore Everything PASS Has to Offer

Free SQL Server and BI Web Events Free 1-day Training Events Regional Event

Local User Groups Around


This is Community Business Analytics Training
the World

Session Recordings PASS Newsletter Free Online Technical Training


Session Evaluations

Submit by 11:59 PM EST


Your feedback is
Friday Nov. 7 to
important and valuable.
WIN prizes
ways to access Evaluation Deadline:
11:59 PM EST, Sunday Nov. 16

Go to Download the GuideBook App Follow the QR code link displayed


passsummit.com/evals and search: PASS Summit 2014 on session signage throughout the
conference venue and in the
program guide
About Me: Reza Rad
DW/BI Architect, Consultant
SQL Server MVP
Author of SQL Server and BI books
Author of SSIS webcast series on RADACAD
Microsoft Certified Trainer
Microsoft Certified Professional
@Rad_Reza a.raad.g@gmail.com

www.rad.pasfu.com www.linkedin.com/in/rezarad
Agenda

Introduction to Power Query


Power Query Formula Language: M
Top Five M Functionalities
Date Dimension with Power Query
Power Query for Office 365 Benefits
Introduction to
Power Query
Power Query For Excel
Free to download!
Wide Range of Data Sources Supported
Online Search
Data Transformations on GUI
Load to Data Model
Query Can be Shared (Power BI)
Demo: Fetch
Movies Data
with Power
Query
Power Query
Formula
Language: M
What is M?
Everything that Happens on GUI works with a Code Behind
Code Behind is a Functional Language: M
More about Formula Language
M is much more powerful than Power Query GUI;
Not all functionalities of M implemented through GUI.
If you want to be Professional In Power Query; You should be
Expert in M
M is a functional language
Structure of M
M is Case Sensitive
M Syntax
let
TableA = #table({"CustomerId", "TranDate","TranCount"},
{
{1,DateTime.FromText("2014-01-01 01:00:00.000"),10},
{1,DateTime.FromText("2014-01-01 02:00:00.000"),5},
{1,DateTime.FromText("2014-01-03 01:00:00.000"),5},
{1,DateTime.FromText("2014-01-04 02:00:00.000"),80}
}),

TableB = #table({"CustomerId", "TranDate","TranCount"},


{
{1,DateTime.FromText("2014-01-01 02:00:00.000"),10},
{1,DateTime.FromText("2014-01-01 03:00:00.000"),5},
{1,DateTime.FromText("2014-01-02 01:00:00.000"),20},
{1,DateTime.FromText("2014-01-02 03:00:00.000"),15},
{2,DateTime.FromText("2014-01-01 01:00:00.000"),5},
{2,DateTime.FromText("2014-01-01 02:00:00.000"),80}
}),
TableATransformed=Table.Sort(
Table.AddColumn(TableA,"Date",each Date.From([TranDate]))
,{"CustomerId","TranDate"}
) ,
TableBTransformed=Table.Sort(
Table.AddColumn(TableB,"Date",each Date.From([TranDate]))
,{"CustomerId","TranDate"}
) ,
TableAGrouped=Table.Group(TableATransformed,{"CustomerId","Date"},{"Total",each List.Last([TranCount])}),
TableBGrouped=Table.Group(TableBTransformed,{"CustomerId","Date"},{"Total",each List.Last([TranCount])})

in
Table.Join(Table.PrefixColumns(TableAGrouped,"TableA"),{"TableA.CustomerId","TableA.Date"},TableBGrouped,{"CustomerId","Date"},JoinKind.FullOuter)
DEMO: Join
Tables with M
Script
Top 5 M
Functionalities
Top Five M Functionalities
Robust List of Built-in Functions

Custom Functions

Error Handling

EACH; Singleton Function

Generator Functions
Robust Built-in Functions
Table Functions Table Functions
Table.AddColumn
Date Functions Table.RemoveColumns

#shared keyword Table.ReorderColumns


Table.SelectColumns
Table.ReplaceValue
Table.Sort
Table.AddIndexColumn
Table.FillDown
DEMO: Table
Functions
Custom Functions
Re-use your code
Reduce redundancy
Increase consistency
Custom Functions
Lamda expression

Parameters (optional,required)

Multi-Line functions
Generators
List can be generated
List.Dates(<start date>,<end date>)
Generates List of Dates from <start date> to <end date>

It can be used as Loop structure


EACH; Singleton Function
Single Valued parameter
Can be applied on transforms to the items in List or Table
DaysInMonthList=List.Transform(MonthList,each
Date.DaysInMonth(DateTime.FromText(Text.From(Year)&"-
"&Text.From(_)&"-01")))
DEMO: Custom
Function,
Generator, Each
Function
Error Handling
Control of Execution when error happens
Sending proper error messages
Preventing failure with messages for troubleshooting
DEMO: Error
Handling
Date Dimension
with Power
Query
Date Dimension
Features
Configurable via table in Excel Sheet
Fiscal Columns
Public Holidays Fetched Live
How it works
Generators; to build the base structure
EACH; to apply transformations on each item in list
Date/Text Functions
Odata
Table Functions
DEMO: Date
Dimension
Power Query for
Office 365
Benefits
Power BI Features
Share Queries
Manage Shared Queries
Find and use a Shared Query
View Usage Analytics for Shared Query
Summary






References to Study More
Power Query Posts on my Blog:
http://rad.pasfu.com/index.php?/categories/15-Power-Query
Power Query Formula Categories online Help:
http://office.microsoft.com/en-001/excel-help/power-query-formula-
categories-HA104122363.aspx
PDFs to Learn M on MSDN:
http://office.microsoft.com/en-nz/excel-help/learn-about-power-query-
formulas-HA104003958.aspx
Power Query for Power BI and Excel (Book, Author; Chris Webb):
http://www.apress.com/9781430266914
Questions?
@Rad_Reza

a.raad.g@gmail.com

www.rad.pasfu.com

www.linkedin.com/in/rezarad
Explore Everything PASS Has to Offer

Free SQL Server and BI Web Events Free 1-day Training Events Regional Event

Local User Groups Around


This is Community Business Analytics Training
the World

Session Recordings PASS Newsletter Free Online Technical Training


Session Evaluations

Submit by 11:59 PM EST


Your feedback is
Friday Nov. 7 to
important and valuable.
WIN prizes
ways to access Evaluation Deadline:
11:59 PM EST, Sunday Nov. 16

Go to Download the GuideBook App Follow the QR code link displayed


passsummit.com/evals and search: PASS Summit 2014 on session signage throughout the
conference venue and in the
program guide

S-ar putea să vă placă și