0% found this document useful (0 votes)
161 views86 pages

Up & Running With PBI

Here are the steps to connect to a CSV file and perform basic transformations in Power BI: 1. Click "Get Data" and select the "Text/CSV" connector. 2. Choose the CSV file you want to connect to, in this case "AdventureWorks_Product.csv". 3. The CSV file will load as a table in the Query Editor. You can now perform transformations like: - Rename columns - Change data types - Filter rows - Sort values - Extract header row as column names - Remove/keep specific columns 4. When done transforming, close and apply the query. The data will load into the data model in Power BI Desktop. You can

Uploaded by

Asmaa Bouhlel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
161 views86 pages

Up & Running With PBI

Here are the steps to connect to a CSV file and perform basic transformations in Power BI: 1. Click "Get Data" and select the "Text/CSV" connector. 2. Choose the CSV file you want to connect to, in this case "AdventureWorks_Product.csv". 3. The CSV file will load as a table in the Query Editor. You can now perform transformations like: - Rename columns - Change data types - Filter rows - Sort values - Extract header row as column names - Remove/keep specific columns 4. When done transforming, close and apply the query. The data will load into the data model in Power BI Desktop. You can

Uploaded by

Asmaa Bouhlel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 86

UP & RUNNING

POWER BI DESKTOP

MS PBI Training – BK MajdEddine


COURSE OUTLINE

Installing Power BI, exploring the Power BI workflow,


1 Introducing Power BI Desktop comparing Power BI vs. Excel, etc.

Connecting to source data, shaping and transforming


2 Connecting & Shaping Data tables, editing, merging and appending queries, etc.

Building relational models, creating table relationships,


3 Creating a Data Model understanding cardinality, exploring filter flow, etc.

Understanding DAXsyntax, adding calculated columns and


4 Adding Calculated Fields with DAX measures, writing common formulas and functions, etc.

Inserting charts and visuals, customizing formats, editing


5 Visualizing Data with Reports interactions, applying filters and bookmarks, etc.

Applying all of the skills developed throughout the course


6 Final Course Project to build a pro-quality B.I. report froma brand new dataset

MS PBI Training – BK MajdEddine


SETTING EXPECTATIONS

1 What you see on your screen may not always match mine
• Power BI Desktop features are updated frequently (product updates released eachmonth)
• NOTE:Power BI is currently only compatible with PC/Windows (not available for Mac)

2 This course is designed to get you up & running with Power BI Desktop
• The goal is to provide a foundational understanding of Power BI desktop; some concepts may be
simplified, and we will not cover some of the more advanced tools (i.e. Mcode, custom Rvisuals, advanced
DAX, etc)

3 Power BI and Power Pivot in Excel are built on the exact same engine
• If you’ve taken my Power Query, Power Pivot & DAXcourse, the first sections will review similar coreconcepts
• Feel free to skip ahead if you’re already comfortable withPower Query and data modeling fundamentals

4 We will not cover Power BI Service as part of this course


• This course will focus on Power BI Desktop specifically; online sharing and collaboration
features (app.powerbi.com) will be covered in depth in a separatecourse

MS PBI Training – BK MajdEddine


Traditional Data Warehouse Architecture

MS PBI Training – BK MajdEddine


Data Warehouse Models
 In a traditional architecture there are three common data warehouse models:
 A virtual data warehouse
 is a set of separate databases, which can be queried together, so a user can
effectively access all the data as if it was stored in one data warehouse.
 A data mart model
 is used for business‐line specific reporting and analysis. In this data warehouse
model, data is aggregated from a range of source systems relevant to a specific
business area, such as sales or finance.
 An enterprise data warehouse model
 prescribes that the data warehouse contain aggregated data that spans the entire
organization.
 This model sees the data warehouse as the heart of the enterprise’s information
system, with integrated data from all business units.

MS PBI Training – BK MajdEddine


Star Schema vs. Snowflake Schema

MS PBI Training – BK MajdEddine


ETL vs. ELT

MS PBI Training – BK MajdEddine


WHY POWER BI?

• Connect, transform and analyze millions of rows of data


• Access data from virtually anywhere (database tables, flat files, cloud services, folders, etc), and
create fully automated data shaping and loading (ETL) procedures

• Build relational models to blend data from multiple sources


• Create table relationships to analyze holistic performance across an entire datamodel

• Define complex calculations using Data Analysis Expressions(DAX)


• Enhance datasets and enable advanced analytics with powerful and portable DAX expressions

• Visualize data with interactive reports & dashboards


• Build custom business intelligence tools with best-in-class visualization and dashboard features

• Power BI is the industry leader among BI platforms


• Microsoft Power BI is intuitive, powerful and absolutely FREE to getstarted

MS PBI Training – BK MajdEddine


POWER BI VS POWER EXCEL
POWER EXCEL POWER BI

“Power Excel” and Power


BI are built on top ofthe
PivotTables Report View
exact same engine!
Data Shaping
(Power Query) • Power BI takes the same
PivotCharts data shaping, modeling
Custom and analytics capabilities
Data Modeling and adds new reporting
Visualization Tools
(Power Pivot) and publishing tools
(R-Visuals, Bookmarks,
Interactions, etc)
Power Map/ Calculated Fields • Transitioning is easy; you
Power View can import an entire data
(DAX)
model directly from
Publishing & Excel!
Collaboration Options
CUBE Functions (Power BI Service)

MS PBI Training – BK MajdEddine


TYPES OF DATA CONNECTORS

Power BI can connect to virtually any type


of source data, including (but not limited
to):

• Flat files & Folders (csv, text, xls, etc)


• Databases (SQL,Access, Oracle, IBM, Azure, etc)
• Online Services (Sharepoint, GitHub, Dynamics
365, Google Analytics, Salesforce, Power BI Service,
etc)
• Others (Web feeds, Rscripts, Spark, Hadoop, etc)

MS PBI Training – BK MajdEddine


THE QUERY EDITOR

Query Editing Tools (Table transformations, calculated columns, etc)

Formula Bar
(this is “M” code)

Table Name
& Properties

Query List
Applied Steps
(like amacro)

MS PBI Training – BK MajdEddine


BASIC TABLE TRANSFORMATIONS
Sort values (A-Z, Low-High, etc.) Change data type (date, $, %, text, etc.)

Promote
header row

Duplicate, move &


rename columns
Chooseor remove columns
Tip: Right-click the
Tip: use the “Remove Other
column header to
Columns” option if youalways
access common tools
want a specific set
Keep or remove rows
Tip: use the “Remove Duplicates”
option to create a new lookup
table from scratch

MS PBI Training – BK MajdEddine


Lab: Connect to CSV File and Basic Transformation

MS PBI Training – BK MajdEddine


Lab: Connect to CSV File and Basic Transformation

1 Click on Get Data and Text/CSV Connector 2 Choose the File AdventureWorks_Product.csv

MS PBI Training – BK MajdEddine


Lab: Connect to CSV File and Basic Transformation

3 An overview of AdventureWorks_Product.csv

4 Click on Edit (Transformer les données)

MS PBI Training – BK MajdEddine


Lab: Connect to CSV File and Basic Transformation

5 Query Editor : Get Source of data

MS PBI Training – BK MajdEddine


Lab: Connect to CSV File and Basic Transformation
6 Query Editor : Types of data

MS PBI Training – BK MajdEddine


Lab: Connect to CSV File and Basic Transformation

7 Query Editor : Sort Data

MS PBI Training – BK MajdEddine


Lab: Connect to CSV File and Basic Transformation
Query Editor : Rename Query
8

MS PBI Training – BK MajdEddine


Lab: Connect to CSV File and Basic Transformation
Query Editor : Delete a Column
9

MS PBI Training – BK MajdEddine


Lab: Connect to CSV File and Basic Transformation
Query Editor : Save and validate
10

MS PBI Training – BK MajdEddine


Lab: Connect to CSV File and Basic Transformation
Power BI : The Data
11

MS PBI Training – BK MajdEddine


Lab: Connect to CSV File and Basic Transformation
Power BI : The ReportView
12

MS PBI Training – BK MajdEddine


Lab: Connect to CSV File and Basic Transformation
12 Power BI : The Relationship View

MS PBI Training – BK MajdEddine


TEXT-SPECIFIC TOOLS

Extract characters from a text


Split a text column based on column based on fixed
either a specific delimiter or lengths, first/last, ranges or
a number of characters delimiters
Tip: Select two or more columnsto
merge (or concatenate) fields
HEYTHIS IS IMPORTANT!
Youcan access many of these tools in both the
“Transform” and “Add Column” menus -- the Format a text column to upper, lower
difference is whether you want to add a new or proper case, or add a prefix or suffix
column or modify an existing one Tip: Use “Trim” to eliminate leading & trailing spaces,
or “Clean” to remove non-printablecharacters

MS PBI Training – BK MajdEddine


Lab: TEXT‐SPECIFIC TOOLS Transformation

MS PBI Training – BK MajdEddine


Lab: Connect to CSV File and Basic Transformation

1 Click on Get Data and Text/CSV Connector 2 Choose the File AdventureWorks_Customer.csv

MS PBI Training – BK MajdEddine


Lab: TEXT‐SPECIFIC TOOLS Transformation
3 Query Editor : Rename the Query « AW_Customer_Lookup »

MS PBI Training – BK MajdEddine


Lab: TEXT‐SPECIFIC TOOLS Transformation
4 Query Editor : « Text Format – Capitalize »

MS PBI Training – BK MajdEddine


Lab: TEXT‐SPECIFIC TOOLS Transformation
5 Query Editor : « Merge Column »

MS PBI Training – BK MajdEddine


Lab: TEXT‐SPECIFIC TOOLS Transformation
6 Query Editor : « Merge Column »

MS PBI Training – BK MajdEddine


Lab: TEXT‐SPECIFIC TOOLS Transformation
7 Query Editor : « Merge Column »

MS PBI Training – BK MajdEddine


Lab: TEXT‐SPECIFIC TOOLS Transformation
8 Query Editor : « Extract characters from a text column based on fixed lengths, first/last, ranges or delimiters»

MS PBI Training – BK MajdEddine


Lab: TEXT‐SPECIFIC TOOLS Transformation
9 Query Editor : « Extract characters from a text column based on fixed lengths, first/last, ranges or delimiters»

MS PBI Training – BK MajdEddine


Lab: TEXT‐SPECIFIC TOOLS Transformation
10 Query Editor : « Extract characters from a text column between 2 delimiters»

MS PBI Training – BK MajdEddine


Lab: TEXT‐SPECIFIC TOOLS Transformation
11 Query Editor : « Extract characters from a text column between 2 delimiters»

MS PBI Training – BK MajdEddine


Lab: TEXT‐SPECIFIC TOOLS Transformation
11 Query Editor : « Replace characters in a text
column»

MS PBI Training – BK MajdEddine


Lab: TEXT‐SPECIFIC TOOLS Transformation
12 Query Editor : « Replace characters in a text column and Capitalize first letter»

MS PBI Training – BK MajdEddine


NUMBER-SPECIFIC TOOLS

Information tools allow


you to define binaryflags
(TRUE/FALSEor 1/0) to
Standard Scientific Trigonometry mark each row in a
Statistics functions allow you to column as even, odd,
evaluate basic stats for the Standard, Scientific and Trigonometry tools allow you
positive or negative
selected column (sum, min/max, to apply standard operations (addition, multiplication,
average, count, countdistinct, etc) division, etc.) or more advanced calculations (power,
logarithm, sine, tangent, etc) to each value in acolumn
Note: These tools return a SINGLEvalue,
and are commonly used to explore a table Note: Unlike the Statistics options, these tools are applied to
rather than prepare it forloading each individual row in thetable

MS PBI Training – BK MajdEddine


Lab: NUMBER‐SPECIFIC TOOLS

MS PBI Training – BK MajdEddine


Lab: NUMBER-SPECIFIC TOOLS
1 Query Editor : « Change Type to Decimal»

MS PBI Training – BK MajdEddine


Lab: NUMBER-SPECIFIC TOOLS
1 Query Editor : « Change Type to Decimal»

MS PBI Training – BK MajdEddine


Lab: NUMBER-SPECIFIC TOOLS
1 Query Editor : « Change Type to Decimal based on Regional Location»

MS PBI Training – BK MajdEddine


Lab: NUMBER-SPECIFIC TOOLS
1 Query Editor : « Formatting type to Decimal using Text Replace»

MS PBI Training – BK MajdEddine


Lab: NUMBER-SPECIFIC TOOLS
1 Query Editor : « Formatting type to Decimal using Text Replace»

MS PBI Training – BK MajdEddine


Lab: NUMBER-SPECIFIC TOOLS
1 Query Editor : « Compute Average»

MS PBI Training – BK MajdEddine


Lab: NUMBER-SPECIFIC TOOLS
1 Query Editor : « Multiplication »

MS PBI Training – BK MajdEddine


Lab: NUMBER-SPECIFIC TOOLS
1 Query Editor : « Rounding »

MS PBI Training – BK MajdEddine


Lab: NUMBER-SPECIFIC TOOLS
2 Query Editor : « Rounding »

MS PBI Training – BK MajdEddine


DATE-SPECIFICTOOLS

Date & Time tools are relatively straight-forward, and include the following options:
• Age: Difference between the current time and the date in eachrow
• Date Only: Removes the time component of a date/time field
• Year/Month/Quarter/Week/Day: Extracts individual components from a date field
(Time-specific options include Hour, Minute, Second, etc.)
• Earliest/Latest: Evaluates the earliest or latest date from a column as a single value (can
only be accessed from the “Transform” menu)

Note: Youwill almost always want to perform these operations from the “Add Column” menuto
build out new fields, rather than transforming an individual date/timecolumn

PRO TIP:
Load up a table containing a single date column and use Date tools to build out an entire calendar
table

MS PBI Training – BK MajdEddine


CREATING A BASIC CALENDAR TABLE

Use pre-defined Date options


in the “Add Column” menu
to quickly build out a
calendar table from a list of
dates

MS PBI Training – BK MajdEddine


Lab: CREATING A BASIC CALENDAR TABLE

MS PBI Training – BK MajdEddine


Lab: CREATING A BASIC CALENDAR TABLE

1 Click on Get Data and Text/CSV Connector 2 Choose the File AdventureWorks_Calandar.csv

MS PBI Training – BK MajdEddine


Lab: CREATING A BASIC CALENDAR TABLE

1 Click on Get Data and Text/CSV Connector 2 Choose the File AdventureWorks_Calandar.csv

MS PBI Training – BK MajdEddine


Lab: CREATING A BASIC CALENDAR TABLE
1 Add Column ‘Name of Day’

MS PBI Training – BK MajdEddine


Lab: CREATING A BASIC CALENDAR TABLE
1 Add Column ‘Name of Day’

MS PBI Training – BK MajdEddine


Lab: CREATING A BASIC CALENDAR TABLE
1 Add Column ‘Start of week, start of year, start of month

MS PBI Training – BK MajdEddine


Lab: CREATING A BASIC CALENDAR TABLE
1 Add Column ‘Start of week, start of year, start of month

MS PBI Training – BK MajdEddine


PROTIP: CREATING A ROLLING CALENDAR

1) Create a new, blank query (Get Data > Blank Query or New Source > Blank Query)

2) In the formula bar, generate a starting date by entering a “literal” (in YYYY, MM, DD format):

3) Click the fX icon to add a new custom step, and enter the following formula exactly as shown:

4) Convert the resulting list into a Table (List Tools > To Table) and format the column as a Date

5) Add calculated Date columns (Year, Month, Week, etc.) as necessary using the Add Column tools

MS PBI Training – BK MajdEddine


Lab: CREATING A ROLLING CALENDAR

MS PBI Training – BK MajdEddine


ADDING INDEX COLUMNS

Index Columns contain a list of


sequential values that can be used to
identify each unique row in a table
(typically starting from 0 or 1)

These columns are often used to


create unique IDs that can be used to
form relationships between tables
(more on that later!)

MS PBI Training – BK MajdEddine


Lab: ADDING INDEX COLUMNS

MS PBI Training – BK MajdEddine


ADDING CONDITIONAL COLUMNS

Conditional Columns allow you to define new fields based


on logical rules and conditions (IF/THEN statements)

In this case we’re creating a new conditional column


called “QuantityType”, which depends on the values in
the “OrderQuantity” column, as follows:

• If OrderQuantity =1, QuantityType =“Single Item”


• If OrderQuantity >1, QuantityType =“Multiple Items”
• Otherwise QuantityType =“Other”

MS PBI Training – BK MajdEddine


Lab: ADDING CONDITIONAL COLUMNS

MS PBI Training – BK MajdEddine


GROUPING & AGGREGATING DATA

Group Byallows you to aggregate your data at a different level


(i.e. transform daily data into monthly, roll up transaction-level data by store, etc)

In this case we’re transforming a daily, transaction-level table into a


summary of “TotalQuantity” rolled up by “ProductKey”

NOTE:Any fields not specified in the Group By settings arelost

MS PBI Training – BK MajdEddine


Lab: GROUPING & AGGREGATING DATA

MS PBI Training – BK MajdEddine


GROUPING & AGGREGATING DATA (ADVANCED)

This time we’re transforming the daily, transaction-level table into a summary
of “TotalQuantity” aggregated by both “ProductKey” and “CustomerKey”
(using the advanced option in the dialogbox)

NOTE:This is similar to creating a PivotTable in Excel and pulling in “Sum of


OrderQuantity” with ProductKey and CustomerKey as rowlabels

MS PBI Training – BK MajdEddine


Lab: GROUPING & AGGREGATING DATA (ADVANCED)

MS PBI Training – BK MajdEddine


PIVOTING & UNPIVOTING

“Pivoting” is a fancy way to describe the process of turning distinct row


values into columns (“pivoting”) or turning columns into rows(“unpivoting”)

Imagine that the table is on a hinge; pivotingis like rotating


it from a vertical to a horizontal layout, and unpivoting is
like rotating it from horizontal to vertical

NOTE:Transpose works very similarly, but doesn’t recognize


unique values; instead, the entire table is transformed so
that each row becomes a column and viceversa

MS PBI Training – BK MajdEddine


Lab: PIVOTING & UNPIVOTING

MS PBI Training – BK MajdEddine


Lab: PIVOTING & UNPIVOTING

1 Click on Get Data and Text/CSV Connector 2 Choose the File UnpivotDemo.csv

MS PBI Training – BK MajdEddine


Lab: PIVOTING & UNPIVOTING

MS PBI Training – BK MajdEddine


Lab: PIVOTING & UNPIVOTING
2 Add Header Column form the first row

MS PBI Training – BK MajdEddine


Lab: PIVOTING & UNPIVOTING
2 Add Header Column form the first row

Sellam

MS PBI Training – BK MajdEddine


Lab: PIVOTING & UNPIVOTING
2 UNPIVOTING

MS PBI Training – BK MajdEddine


Lab: PIVOTING & UNPIVOTING
2 PIVOTING

MS PBI Training – BK MajdEddine


Lab: PIVOTING & UNPIVOTING

MS PBI Training – BK MajdEddine


MERGING QUERIES

Merging queries allows you to join tablesbased


on a common column (like VLOOKUP)

In this case we’re merging the AW_Sales_Data


table with the AW_Product_Lookup table, which
share a common “ProductKey” column

NOTE:Merging adds columns to an existing table

HEYTHIS IS IMPORTANT!
Just because you can merge
tables, doesn’t mean you should.
In general, it’s better to keep tables
separate and define relationships
between them (more on that later!)

MS PBI Training – BK MajdEddine


Lab: MERGING QUERIES

MS PBI Training – BK MajdEddine


APPENDING QUERIES

Appending queries allows you to combine (or stack) tables


that share the exact same column structure and data types

In this case we’re appending the


AdventureWorks_Sales_2015 table to the
AdventureWorks_Sales_2016 table, which is valid since
they share identical table structures

NOTE:Appending adds rows to an existing table

PRO TIP:
Use the “Folder” option (Get Data > More > Folder) to append all files within a folder (assuming they share
the same structure); as you add new files, simply refresh the query and they will automatically append!

MS PBI Training – BK MajdEddine


Lab: APPENDING QUERIES

MS PBI Training – BK MajdEddine


DEFINING DATA CATEGORIES

From the “Modeling” tab in theData view, you can


edit field properties to define specificcategories

This is commonly used to help Power BI accurately


map location-based fields like addresses, countries,
cities, latitude/longitude coordinates, zip codes, etc

MS PBI Training – BK MajdEddine


Lab: DEFINING DATA CATEGORIES

MS PBI Training – BK MajdEddine


DEFINING HIERARCHIES
Hierarchies are groups of nested columns that reflect multiple levels of granularity
• For example, a “Geography” hierarchy might include Country, State, and City columns
• Each hierarchy can be treated as a single item in tables and reports, allowing users to “drill up”
and “drill down” through different levels of the hierarchy in a meaningful way

1) From within the Data view, right-click a field 2) This creates a hierarchy field 3) Right-click other fields
(or click the ellipsis) and select “New hierarchy” containing “Start of Year”, which (like “Start of Month”) and
(here we’ve selected “Start of Year”) we’ve renamed “Date Hierarchy” select “Add to Hierarchy”

MS PBI Training – BK MajdEddine


Lab: DEFINING HIERARCHIES

MS PBI Training – BK MajdEddine


BEST PRACTICES : CONNECTING & SHAPING DATA

Get yourself organized, before loading the data into Power BI


• Define clear and intuitive table names (no spaces!) from the start; updatingthem later
can be a headache, especially if you’ve referenced them in multipleplaces
• Establish a file/folder structure that makes sense from the start, toavoid having to
modify data source settings if filenames or locations change

Disabling report refresh for any static sources


• There’s no need to constantly refresh sources that don’t update frequently (or at all),
like lookups or static data tables; only enable refresh for tables that will be changing

When working with large tables, only load the data you need
• Don’t include hourly data when you only need daily, or product-level transactions
when you only care about store-level performance; extra data willonly slow you down

MS PBI Training – BK MajdEddine

You might also like