Professional Documents
Culture Documents
Microsoft365 Automation 2021
Microsoft365 Automation 2021
Microsoft365 Automation 2021
Automation
- Ken Ding
What is Microsoft 365?
“Our cloud productivity offering has grown well beyond what people traditionally think of
as ‘Office.’ […] we’re breathing new life into these apps with the help of the cloud and AI, and
we’re adding new, born-in-the-cloud experiences like Teams, Stream, Forms, and Planner. […] It’s
Office and a whole lot more.”
• Use case 2 – Neighborhood Rating Report with Power Automate and Forms
Source: https://precondo.ca/toronto-airbnb-condos-rules/
Learning Outcome
• Tool: Power BI
• Data: Airbnb - Inside Airbnb
• Business:
• Analyze Toronto Airbnb market size:
• Average price
• Number of listings
• Number of reviews over time
• How is Airbnb really being used in your neighborhoods?
• Does Airbnb really affect Toronto’s long-term rental supply?
• Availability analysis
• Listings per host
Structure Dirty
Dirty Data
• Wrong
format
• Missing
Content Dirty • Invalid value
• Duplicated
• ……..
• Tool: Power BI
• Data: Toronto Open - https://open.toronto.ca/
• Business – deal with an ambiguous problem:
• Analyze Toronto 140 neighborhoods’ profile
• Rank neighborhood based on different criteria
• Safety (based on crimes)
• Income
• Diversity (based on the percentage of visible minorities)
• Airbnb activities
• Data manipulation and visualization:
• Fetch data from web source to Power BI
• Advanced data cleaning
Practice 2
before data
loaded into Custom Column Calculated Measure
model
Column
Creation
I. Created in Query Editor I. Created in Report I. Created in Report happens
II. Use Power Query (M formula view or Data view view or Data view after data
language) to create II. Use DAX to create II. Use DAX to create loaded into
III. Appears in Fields list without III. Appears in Fields III. Appears in Fields model
special icon list with a special list with a special
icon icon
IV. Calculated for each row IV. Calculated for each row IV. Calculated only when it is used in a
V. Saved before data loaded V. Saved back into the visual
into model model => take up space V. Not saved into the model
• Use a Calculated Column / Custom Column when you want to evaluate each row
• If Custom Column can do the job, use it because Power Query can help ‘prune’ data
• Use a Measure when you need an aggregate
Deal with Structure Dirty Data
• Most of open datasets are disorganized
Data Source Characteristic City of Toronto Agincourt North Agincourt South-Malvern West Alderwood …..
City of Toronto Neighbourhood Number 129 128 20…..
City of Toronto TSNS2020 Designation No Designation No Designation No Designation …..
Census Profile 98-316-X2016001 Population Change 2011-2016 4.50% -3.90% 8.00% 1.30% …..
Census Profile 98-316-X2016001 Total private dwellings 1,179,057 9,371 8,535 4,732…..
Census Profile 98-316-X2016001 Private dwellings occupied by usual residents 1,112,929 9,120 8,136 4,616…..
Census Profile 98-316-X2016001 Population density per square kilometre 4,334 3,929 3,034 2,435…..
Census Profile 98-316-X2016001 Land area in square kilometres 630.2 7.41 7.83 4.95 …..
Census Profile 98-316-X2016001 Children (0-14 years) 398,135 3,840 3,075 1,760…..
Census Profile 98-316-X2016001 Youth (15-24 years) 340,270 3,705 3,360 1,235…..
Census Profile 98-316-X2016001 Working Age (25-54 years) 1,229,555 11,305 9,965 5,220…..
Census Profile 98-316-X2016001 Pre-retirement (55-64 years) 336,670 4,230 3,265 1,825…..
Census Profile 98-316-X2016001 Seniors (65+ years) 426,945 6,045 4,105 2,015…..
Census Profile 98-316-X2016001 Older Seniors (85+ years) 66,000 925 555 320…..
Pivot vs. Unpivot vs. Transpose
Reshape data by using Pivot, Unpivot and Transpose:
• Transformation engine in Power Query has many prebuilt functions used for cleaning data
Power Query will always create the attribute-value pair by using two columns:
• Attribute: The name of the column headings that were unpivoted
• Value: The values that were underneath each of the unpivoted column headings
Pivot vs. Unpivot vs. Transpose
Reshape data by using Pivot, Unpivot and Transpose:
Transpose Table Rotate table 90 degrees => turning row to columns and columns to
rows
• Only the contents of the table will be transposed during the transpose
operation; the column headers of the initial table will be lost =>
When you need to use Transpose, you should delete any
Promoted Header step
Practice 3
Similar to
Group By
clause in SQL
Merge Queries in Power Query
• A merge queries operation joins two existing tables together based on matching values from
one or multiple columns
• When you have one or more columns that you’d like to add to another query, you merge the
queries.
Similar to Join
in SQL
Merge Queries in Power Query
• A join kind specifies how a merge operation will be performed:
Left outer All rows from the left table, matching rows
from the right table
Right outer All rows from the right table, matching rows
from the left table
Full outer All rows from both tables
To avoid:
• Create too complex relationships
• Create a big data including
everything (losing flexibility) • Relationship and Merge Queries (Join) can be used together
Use Case 1:
Neighborhood Rating Tool with Power BI
• Airbnb analysis
• Toronto Neighborhood Profile Analysis
• Toronto Neighborhood Rating Tool
Decision Matrix Analysis
Decision Matrix Analysis is a useful technique for making a decision by weighting different
factors based on their importance
Calculate score value for each metric • Collect and analyze data
• Define methodologies to
calculate score based on
analytics
Example:
▪ Income 25th percentile =
PERCENTILE.INC ( 'Neighborhood Rating'[% of $100K+Income], 0.25 )
• RETURN – can be used together with VAR to consume variables defined in previous VAR
statements.
• DAX Syntax:
VAR <name> = <expression>
[VAR <name2> = <expression2> [...]]
RETURN <result_expression>
DAX Functions – VAR and Return
Use variables (VAR) in DAX formulas can:
• Improve performance
• Improve readability
• Simplify debugging
• Reduce complexity
Example:
▪ Airbnb Score =
VAR high =
PERCENTILE.INC ( 'Neighborhood Rating'[Tot_listings], 0.75 )
VAR mid =
PERCENTILE.INC ( 'Neighborhood Rating'[Tot_listings], 0.50 )
VAR low =
PERCENTILE.INC ( 'Neighborhood Rating'[Tot_listings], 0.25 )
RETURN
IF (
'Neighborhood Rating'[Tot_listings] <= low,
1,
IF (
'Neighborhood Rating'[Tot_listings] <= mid,
2,
IF ( 'Neighborhood Rating'[Tot_listings] <= high, 3, 4 )
)
)
Practice 4.2
• What-if parameters give you the flexibility to dynamically change the output of your queries
depending on their value
Use What-if Parameters
Increment is how much • In addition to creating the
the parameter will adjust parameter, creating a what-if
when interacted with in a parameter also creates a measure
report • both the parameter and the
measure become part of your
model
• RANKX – Returns the ranking of a number in a list of numbers for each row in the table
argument
• DAX Syntax:
RANKX(<table>, <expression>[, <value>[, <order>[, <ties>]]])
• table: returns a table of data over which the expression is evaluated
• expression: returns a single scalar value
• value(optional): returns a single scalar value whose rank is to be found
• order: 0(default) - the highest number in expression gets rank 1; 1 - the lowest number gets rank 1
• Ties: skip(default); dense - the next rank value, after a tie, is the next rank value
Example:
▪ Rank =
RANKX (
ALL ( 'Neighborhood Rating'[Neighborhood] ),
[Weighted Average Score],
,
0,
DENSE
)
DAX Functions – ALL
• ALL – Returns all the rows in a table, or all the values in a column, ignoring any filters that might
have been applied
• It is useful for clearing filters and creating calculations on all the rows in a table
• DAX Syntax:
ALL( [<table> | <column>[, <column>[, <column>[,…]]]] )
• table: The table that you want to clear filters on
• Column: the column that you want to clear filters on.
This function is not used by itself, but serves as an intermediate function that can be used to change the set of
results over which some other calculation is performed
Example:
▪ Rank =
RANKX (
ALL ( 'Neighborhood Rating'[Neighbourhood] ),
[Weighted Average Score],
,
0,
DENSE
)
Use Case 2:
Neighborhood Rating Report with Power Automate and Forms
Use Case 3:
Power Automate Desktop
Thank You
- Ken Ding