DA - Lab Manual - PowerBI
DA - Lab Manual - PowerBI
DA - Lab Manual - PowerBI
Power BI – Labs
DATA ANALYTICS – POWER BI LAB
Contents
Lab 01A - Getting Started ..................................................................................................................................... 7
Overview........................................................................................................................................................... 7
Exercise 1: Getting Started ............................................................................................................................... 7
Task 1: Record your account details ............................................................................................................. 7
Task 2: Sign in to the Power BI service ......................................................................................................... 8
Task 3: Create a workspace .......................................................................................................................... 9
Task 4: Open Power BI Desktop .................................................................................................................. 11
Task 5: Update the lab database ................................................................................................................ 12
Lab 02A - Preparing Data in Power BI Desktop................................................................................................... 14
Overview......................................................................................................................................................... 14
Exercise1: Prepare Data.................................................................................................................................. 14
Task 1: Save the Power BI Desktop file ....................................................................................................... 14
Task 2: Set Power BI Desktop options ........................................................................................................ 15
Task 3: Get data from SQL Server ............................................................................................................... 18
Task 4: Preview SQL Server queries ............................................................................................................ 20
Task 5: Get data from a CSV file ................................................................................................................. 26
Task 6: Get additional data from a CSV file ................................................................................................ 27
Finish up...................................................................................................................................................... 28
Lab 03A - Loading Data in Power BI Desktop...................................................................................................... 30
Overview......................................................................................................................................................... 30
Exercise 1: Load Data ...................................................................................................................................... 30
Task 1: Configure the Salesperson query ................................................................................................... 30
Task 2: Configure the SalespersonRegion query ........................................................................................ 35
Task 3: Configure the Product query .......................................................................................................... 36
Task 4: Configure the Reseller query .......................................................................................................... 39
Task 5: Configure the Region query............................................................................................................ 42
Task 6: Configure the Sales query............................................................................................................... 43
Task 7: Configure the Targets query ........................................................................................................... 47
Task 8: Configure the ColorFormats query ................................................................................................. 52
Task 9: Update the Product query .............................................................................................................. 52
Task 10: Update the ColorFormats query................................................................................................... 55
Finish up...................................................................................................................................................... 56
Lab 04A - Data Modeling in Power BI Desktop ................................................................................................... 58
Overview......................................................................................................................................................... 58
Exercise 1: Create Model Relationships ......................................................................................................... 58
Task 1: Create model relationships ............................................................................................................ 58
Exercise 2: Configure Tables ........................................................................................................................... 64
Task 1: Configure the Product table ........................................................................................................... 64
Task 2: Configure the Region table ............................................................................................................. 67
Task 3: Configure the Reseller table ........................................................................................................... 68
Task 4: Configure the Sales table ................................................................................................................ 69
Task 5: Bulk update properties ................................................................................................................... 70
Exercise 3: Review the Model Interface ......................................................................................................... 72
Task 1: Review the model interface ........................................................................................................... 72
Exercise 4: Create Quick Measures ................................................................................................................ 75
Task 1: Create quick measures ................................................................................................................... 75
Finish up...................................................................................................................................................... 80
Lab 05A - Advanced Data Modeling in Power BI Desktop .................................................................................. 82
Overview......................................................................................................................................................... 82
Exercise 1: Create a Many-to many Relationship ........................................................................................... 82
Task 1: Create a many-to-many relationship.............................................................................................. 82
Task 2: Relate the Targets table ................................................................................................................. 86
Exercise 2: Enforce row-level security ............................................................................................................ 87
Task 1: Enforce row-level security .............................................................................................................. 87
Finish up...................................................................................................................................................... 90
Lab 06A - Using DAX in Power BI Desktop, Part 1............................................................................................... 92
Overview......................................................................................................................................................... 92
Exercise 1: Create Calculated Tables .............................................................................................................. 92
Task 1: Create the Salesperson table ......................................................................................................... 92
Task 2: Create the Date table ..................................................................................................................... 94
Task 3: Create calculated columns ............................................................................................................. 96
Task 4: Complete the Date table .............................................................................................................. 101
Task 5: Mark the Date table...................................................................................................................... 102
Exercise 2: Create Measures ........................................................................................................................ 103
Task 1: Create simple measures ............................................................................................................... 103
Task 2: Create additional measures.......................................................................................................... 108
Finish up.................................................................................................................................................... 111
Lab 06B - Using DAX in Power BI Desktop, Part 2 ............................................................................................. 112
Overview....................................................................................................................................................... 112
Overview....................................................................................................................................................... 169
Exercise 1: Create a Dashboard .................................................................................................................... 169
Task 1: Create a dashboard ...................................................................................................................... 169
Task 2: Edit tile details .............................................................................................................................. 173
Task 3: Configure an alert ......................................................................................................................... 175
Exercise 2: Refresh the Dataset .................................................................................................................... 177
Task 1: Update the lab database .............................................................................................................. 177
Task 2: Refresh the Power BI Desktop file ................................................................................................ 178
Exercise 3: Review the Dashboard ............................................................................................................... 179
Task 1: Review the dashboard .................................................................................................................. 179
Lab 11A - Data Analysis in Power BI Desktop ................................................................................................... 181
Overview....................................................................................................................................................... 181
Exercise 1: Create the Report ....................................................................................................................... 181
Task 1: Create the report .......................................................................................................................... 181
Exercise 2: Create a Scatter Chart ................................................................................................................ 182
Task 1: Create an animated scatter chart ................................................................................................. 182
Exercise 3: Create a Forecast ........................................................................................................................ 185
Task 1: Create a forecast .......................................................................................................................... 185
Exercise 4: Work with a Decomposition Tree............................................................................................... 189
Task 1: Work with a decomposition tree.................................................................................................. 189
Exercise 5: Work with Key Influencers ......................................................................................................... 192
Task 1: Work with key influencers ............................................................................................................ 192
Finish up.................................................................................................................................................... 195
Lab 12A - Publishing and Sharing Power BI Content ........................................................................................ 196
Overview....................................................................................................................................................... 196
Exercise 1: Configure Dataset Security ......................................................................................................... 196
Task 1: Configure dataset security............................................................................................................ 196
Exercise 2: Share a Dashboard ..................................................................................................................... 197
Task 1: Share a dashboard ........................................................................................................................ 197
Task 2: Open the shared dashboard ......................................................................................................... 198
Exercise 3: Publish an App ............................................................................................................................ 199
In this lab, you connect to the classroom virtual machine and setup the environment. Before
commencing this lab, you must have received an account and password. It’s important that
you complete the labs by using the provided account.
• Create a workspace
In this task, you will open the MySettings.txt file, and record your account details.
An account has been provided to you by your instructor, and it’s important that you use this
account to complete all of the labs. If an account was not provided to you, please browse
to https://powerbi.microsoft.com/en-us/documentation/powerbi-admin-signing-up-for-power-
bi-with-a-new-office-365-trial and follow the steps to create an account before continuing
with this lab.
1. To open File Explorer, on the taskbar, click the File Explorer program shortcut.
4. In the MySettings.txt file, enter your account name and password next to the labels.
5. To save the MySettings.txt file, on the File menu, select Save (or press Ctrl+S).
1. To open Edge, on the taskbar, click the Microsoft Edge program shortcut.
Tip: You can also use the Power BI Service favorite on the Edge favorites bar.
5. When prompted to update the password, reenter the provided password, and then
enter and confirm a new password. Be sure to update the MySettings.txt file with
your new password.
8. In the Power BI service, at the top-right corner, if the “New Look” is not enabled, click
the slider control to turn it on.
In this task, you will create a workspace. You will also upgrade your account to Power BI Pro.
All content you develop in this course will be added to this workspace.
2. When prompted to upgrade your account to Power BI Pro, click Try Free.
A Power BI Pro license is required to create and work with workspaces. It’s also required
when sharing content. The trial will allow you to work with Pro features for up to 60
days.
3. When prompted to start the 60-day free Pro trial, click Start Trial.
6. In the Create a Workspace pane (located at the right), in the Workspace Name box,
enter a name for your workspace.
The name you enter must be unique within the tenant. We suggest you name the
workspace Sales Analysis, and that you also append your initials. For example, the
name could be Sales Analysis AB.
In this task, you will open Power BI Desktop, and then sign in using your account.
26. To open the Power BI Desktop, on the taskbar, click the Microsoft Power BI Desktop
shortcut.
28. Complete the sign in process by using the MySettings.txt account details.
29. In Power BI Desktop, at the top-right corner, verify that you see your account.
2. In the Windows PowerShell window, when prompted to enter your account, paste in
your account name from the MySettings.txt file.
These facts will become relevant when implementing row-level security in Lab 03B.
In this lab, you commence the development of a Power BI Desktop solution for the
Adventure Works company. It involves connecting to source data, previewing the data, and
using data preview techniques to understand the characteristics and quality of the source
data.
In this task, you will first save the Power BI Desktop file.
1. In Power BI Desktop, click the File ribbon tab to open the backstage view.
2. Select Save.
5. Click Save.
Tip: You can also save the file by click the Save icon located at the top-right.
1. In Power BI Desktop, click the File ribbon tab to open the backstage view.
2. At the left, select Options and Settings, and then select Options.
3. In the Options window, at the left, in the Current File group, select Data Load.
The Data Load settings for the current file allow setting options that determine default
behaviors when modeling.
4. In the Relationships group, uncheck the two options that are checked.
While these two options can be helpful when developing a data model, they have been
disabled to support the lab experience. When you create relationships in Lab 03A, you
will learn why you are adding each one.
5. Click OK.
In this task, you will create queries based on SQL Server tables.
1. On the Home ribbon tab, from inside the Data group, click SQL Server.
2. In the SQL Server Database window, in the Server box, enter localhost.
In the labs, you will connect to the SQL Server database by using localhost. This isn’t a
recommended practice, however, when creating your own solutions. It’s because
gateway data sources cannot resolve localhost.
3. Click OK.
5. Click Connect.
The preview allows you to determine the columns and a sample of rows.
o DimEmployee
o DimEmployeeSalesTerritory
o DimProduct
o DimReseller
o DimSalesTerritory
o FactResellerSales
11. To apply transformations to the data of the selected tables, click Transform Data.
You won’t be transforming the data in this lab. The objectives of this lab are to explore
and profile the data in the Power Query Editor window.
In this task, you will preview the data of the SQL Server queries. First, you will learn relevant
information about the data. You will also use column quality, column distribution, and
column profile tools to understand the data, and assess data quality.
1. In the Power Query Editor window, at the left, notice the Queries pane.
The Queries pane contains one query for each selected table.
The DimEmployee table stores one row for each employee. A subset of the rows
represent the salespeople, which will be relevant to the model you’ll develop.
3. At the bottom left, in the status bar, notice the table statistics—the table has 33
columns, and 296 rows.
5. Notice that the last five columns contain Table or Value links.
These five columns represent relationships to other tables in the database. They can be
used to join tables together. You will join tables in Lab 03A.
6. To assess column quality, on the View ribbon tab, from inside the Data
Preview group, check Column Quality.
Column quality allows you to easily determine the percentage of valid, error, or empty
values.
7. For the Position column (sixth last column), notice that 94% of rows are empty (null).
8. To assess column distribution, on the View ribbon tab, from inside the Data
Preview group, check Column Distribution.
9. Review the Position column again, and notice that there are four distinct values, and
one unique value.
10. Review the column distribution for the EmployeeKey (first) column—there are 296
distinct values, and 296 unique values.
When the distinct and unique counts are the same, it means the column contains
unique values. When modeling, it’s important that some tables contain unique
columns. They will be used to create one-to-many relationships, which you will do
in Lab 04A.
The DimEmployeeSalesTerritory table stores one row for each employee and the
sales territory regions they manage. The table supports relating many regions to a
single employee. Some employees manage one, two, or possibly more regions. When
you model this data, you will need to define a many-to-many relationship, which you
will do in Lab 05A.
The DimProduct table contains one row per product sold by the company.
When you add transformations to this query in the next lab, you’ll use
the DimProductSubcategory column to join tables.
The DimReseller table contains one row per reseller. Resellers sell, distribute, or value
add Adventure Works’ products.
16. To view column values, on the View ribbon tab, from inside the Data Preview group,
check Column Profile.
18. Notice that a new pane opens beneath the data preview pane.
20. Notice the data quality issue: there are two labels for warehouse (Warehouse, and
the misspelled Ware House).
21. Hover the cursor over the Ware House bar, and notice that there are five rows with
this value.
In the next lab, you will apply a transformation to relabel these five rows.
The DimSalesTerritory table contains one row per sales region, including Corporate
HQ (headquarters). Regions are assigned to a country, and countries are assigned to
groups. In Lab 04A, will create a hierarchy to support analysis at region, country, or
group level.
The FactResellerSales table contains one row per sales order line—a sales order
contains one or more line items.
24. Review the column quality for the TotalProductCost column, and notice that 8% of
the rows are empty.
Missing TotalProductCost column values is a data quality issue. To address the issue,
in the next lab you will apply transformations to fill in missing values by using the
product standard cost, which is stored in the DimProduct table.
1. To add a new query, in the Power Query Editor window, on the Home ribbon tab,
from inside the New Query group, click the New Source down-arrow, and then
select Text/CSV.
3. Click Open.
5. Click OK.
The ResellerSalesTargets CSV file contains one row per salesperson, per year. Each
row records 12 monthly sales targets (expressed in thousands). The business year for
the Adventure Works company commences on July 1.
When there isn’t a monthly sales target, a hyphen character is stored instead.
8. Review the icons in each column header, to the left of the column name.
The icons represent the column data type. 123 is whole number, and ABC is text.
In the next lab, you’ll apply many transformations to achieve a different shaped result
consisting of only three columns: Date, EmployeeKey, and TargetAmount.
In this task, you will create an additional query based on a different CSV file.
The ColorFormats CSV file contains one row per product color. Each row records the
HEX codes to format background and font colors. In the next lab, you will integrate this
data with the DimProduct query data.
Finish up
1. On the View ribbon tab, from inside the Data Preview group, uncheck the three data
preview options:
o Column quality
o Column distribution
o Column profile
2. To save the Power BI Desktop file, on the File backstage view, select Save.
Applying the queries will load their data to the data model. You’re not ready to do that,
as there are many transformations that must be applied first.
In the next lab, you will apply various transformations to the queries, and then apply
the queries to load them to the data model.
In this lab, you will commence apply transformations to each of the queries created in the
previous lab. You will then apply the queries to load each as a table to the data model.
If you’re not confident you completed the previous lab successfully, you can open the previous
lab’s solution file, which is found in the D:\DA100\Lab02A\Solution folder.
2. To rename the query, in the Query Settings pane (located at the right), in
the Name box, replace the text with Salesperson, and then press Enter.
The query name will determine the model table name. It’s recommended to define
concise, yet friendly, names.
3. In the Queries pane, verify that the query name has updated.
You will now filter the query rows to retrieve only employees who are salespeople.
4. To locate a specific column, on the Home ribbon tab, from inside the Manage
Columns group, click the Choose Columns down-arrow, and then select Go to
Column.
Tip: This technique is useful when a query contains many columns. Usually, you can
simply horizontally scroll to locate the column.
5. In the Go to Column window, to order the list by column name, click the AZ sort
button, and then select Name.
7. To filter the query, in the SalesPersonFlag column header, click the down-arrow, and
then uncheck FALSE.
8. Click OK.
9. In the Query Settings pane, in the Applied Steps list, notice the addition of
the Filtered Rows step.
Each transformation you create results in additional step logic. It’s possible to edit or
delete steps. It’s also possible to select a step to preview the query results at that stage
of transformation.
10. To remove columns, on the Home ribbon tab, from inside the Manage
Columns group, click the Choose Columns icon.
11. In the Choose Columns window, to uncheck all columns, uncheck the (Select All
Columns) item.
o EmployeeKey
o EmployeeNationalIDAlternateKey
o FirstName
o LastName
o Title
o EmailAddress
14. In the Applied Steps list, notice the addition of another query step.
15. To create a single name column, first select the FirstName column header.
16. While pressing the Ctrl key, select the LastName column.
17. Right-click either of the select column headers, and then in the context menu,
select Merge Columns.
18. In the Merge Columns window, in the Separator dropdown list, select Space.
19. In the New Column Name box, replace the text with Salesperson.
22. Replace the text with EmployeeID, and then press Enter.
When instructed to rename columns, it’s important that you rename them exactly as
described.
23. Use the previous steps to rename the EmailAddress column to UPN.
UPN is an acronym for User Principal Name. The values in this column will be used
when you configure row-level security in Lab 05A.
24. At the bottom-left, in the status bar, verify that the query has five columns and 18
rows.
It’s important that you do not proceed if your query does not produce the correct
result—it won’t be possible to complete later labs. If it doesn’t, refer back to the steps in
this task to fix any problems.
3. To remove the last two columns, first select the DimEmployee column header.
4. While pressing the Ctrl key, select the DimSalesTerritory column header.
5. Right-click either of the select column headers, and then in the context menu,
select Remove Columns.
6. In the status bar, verify that the query has two columns and 39 rows.
When detailed instructions have already been provided in the labs, the lab steps will now
provide more concise instructions. If you need the detailed instructions, you can refer back to
other tasks.
3. Locate the FinishedGoodsFlag column, and then filter the column to retrieve
products that are finished goods (i.e. TRUE).
o ProductKey
o EnglishProductName
o StandardCost
o Color
o DimProductSubcategory
Query column names must always be unique. When checked, this checkbox would
prefix each column with the expanded column name (in this
case DimProductSubcategory). Because it’s known that the selected columns don’t
collide with columns in the Product query, the option is deselected.
11. Notice that the transformation resulted in two columns, and that
the DimProductCategory column has been removed.
o EnglishProductName to Product
o EnglishProductSubcategoryName to Subcategory
o EnglishProductCategoryName to Category
14. In the status bar, verify that the query has six columns and 397 rows.
o ResellerKey
o BusinessType
o RellerName
o DimGeography
4. Expand the DimGeography column, to include only the following three columns:
o City
o StateProvinceName
o EnglishCountryRegionName
5. In the Business Type column header, click the down-arrow, and then review the
items, and the incorrect spelling of warehouse.
50. Right-click the Business Type column header, and then select Replace Values.
o ResellerName to Reseller
o StateProvinceName to State-Province
o EnglishCountryRegionName to Country-Region
54. In the status bar, verify that the query has six columns and 701 rows.
o SalesTerritoryKey
o SalesTerritoryRegion
o SalesTerritoryCountry
o SalesTerritoryGroup
o SalesTerritoryRegion to Region
o SalesTerritoryCountry to Country
o SalesTerritoryGroup to Group
6. In the status bar, verify that the query has four columns and 10 rows.
o SalesOrderNumber
o OrderDate
o ProductKey
o ResellerKey
o EmployeeKey
o SalesTerritoryKey
o OrderQuantity
o UnitPrice
o TotalProductCost
o SalesAmount
o DimProduct
4. Expand the DimProduct column, and then include the StandardCost column.
5. To create a custom column, on the Add Column ribbon tab, from inside
the General group, click Custom Column.
6. In the Custom Column window, in the New Column Name box, replace the text
with Cost.
7. In the Custom Column Formula box, enter the following expression (after the equals
symbol):
Power Query
This expression tests if the TotalProductCost value is missing. If it is, produces a value
by multiplying the OrderQuantity value by the StandardCost value; otherwise, it uses
the existing TotalProductCost value.
9. Click OK.
o TotalProductCost
o StandardCost
o OrderQuantity to Quantity
o SalesAmount to Sales
12. To modify the column data type, in the Quantity column header, at the left of the
column name, click the 1.2 icon, and then select Whole Number.
Configuring the correct data type is important. When the column contains numeric
value, it’s also important to choose the correct type if you expect to perform
mathematic calculations.
13. Modify the following three column data types to Fixed Decimal Number.
o Unit Price
o Sales
o Cost
The fixed decimal number data type stores values with full precision, and so requires
more storage space that decimal number. It’s important to use the fixed decimal
number type for financial values, or rates (like exchange rates).
14. In the status bar, verify that the query has 10 columns and 999+ rows.
A maximum of 1000 rows will be loaded as preview data for each query.
4. Right-click either of the select column headers, and then in the context menu,
select Unpivot Other Columns.
5. Notice that the column names now appear in the Attribute column, and the values
appear in the Value column.
o Value to Target
You will now apply transformations to produce a date column. The date will be derived
from the Year and MonthNumber columns. You will create the column by using
the Columns From Examples feature.
12. On the Add Column ribbon tab, from inside the General group, click The Column
From Examples icon.
13. Notice that the first row is for year 2017 and month number 7.
14. In the Column1 column, in the first grid cell, commence enter 7/1/2017, and then
press Enter.
The virtual machine uses US regional settings, so this date is in fact July 1, 2017.
15. Notice that the grid cells update with predicted values.
The feature has accurately predicted that you are combining values from two
columns.
16. Notice also the formula presented above the query grid.
17. To rename the new column, double-click the Merged column header.
o Year
o MonthNumber
o TargetMonth as date
22. To multiply the Target values by 1000, select the Target column header, and then on
the Transform ribbon tab, from inside the Number Column group, click Standard,
and then select Multiply.
25. In the status bar, verify that the query has three columns and 809 rows.
3. On the Home ribbon tab, from inside the Transform group, click Use First Row as
Headers.
4. In the status bar, verify that the query has three columns and 10 rows.
In this task, you will update the Product query by merging the ColorFormats query.
2. To merge the ColorFormats query, on the Home ribbon tab, from inside
the Combine group, click Merge Queries.
Merging queries allows integrating data, in this case from different data sources (SQL
Server and a CSV file).
3. In the Merge window, in the Product query grid, select the Color column header.
6. When the Privacy Levels window opens, for each of the two data sources, in the
corresponding dropdown list, select Organizational.
Privacy levels can be configured for data source to determine whether data can be
shared between sources. Setting each data source as Organizational allows them to
share data, if necessary. Note that Private data sources can never be shared with other
data sources. It doesn’t mean that Private data cannot be shared; it means that the
Power Query engine cannot share data between the sources.
7. Click Save.
10. In the status bar, verify that the query now has eight columns and 397 rows.
In this task, you will update the ColorFormats to disable its load.
3. In the Query Properties window, uncheck the Enable Load To Report checkbox.
Disabling the load means it will not load as a table to the data model. This is done
because the query was merged with the Product query, which is enabled to lad to the
data model.
4. Click OK.
Finish up
o Salesperson
o SalespersonRegion
o Product
o Reseller
o Region
o Sales
o Target
2. To load the data model, on the File backstage view, select Close & Apply.
3. In the Fields pane (located at the right), notice the seven tables loaded to the data
model.
In this lab, you will commence developing the data model. It will involve creating
relationships between tables, and then configuring table and column properties to improve
the friendliness and usability of the data model. You will also create hierarchies and create
quick measures.
• Create hierarchies
If you’re not confident you completed the previous lab successfully, you can open the
previous lab’s solution file, which is found in the D:\DA100\Lab03A\Solution folder.
2. If you do not see all seven tables, scroll horizontally to the right, and then drag and
arrange the tables more closely together so they can all be seen at the same time.
In Model view, it’s possible to view each table and relationships (connectors between
tables). Presently, there are no relationships because in Lab 02A, you disabled the data
load relationship options.
3. To return to Report view, at the left, click the Report view icon.
4. To view all table fields, in the Fields pane, right-click an empty area, and then
select Expand All.
5. To create a table visual, in the Fields pane, from inside the Product table, check
the Category field.
From now on, the labs will use a shorthand notation to reference a field. It will look like
this: Product | Category.
6. To add a column to the table, in the Fields pane, check the Sales | Sales field.
7. Notice that the table visual lists four product categories, and that the sales value is
the same for each, and the same for the total.
The issue is that the table is based on fields from different tables. The expectation is
that each product category displays the sales for that category. However, because there
isn’t a model relationship between these tables, the Sales table is not filtered. You will
now add a relationship to propagate filters between the tables.
8. On the Modeling ribbon tab, from inside the Relationships group, click Manage
Relationships.
9. In the Manage Relationships window, notice that no relationships are yet defined.
11. In the Create Relationship window, in the first dropdown list, select
the Product table.
12. In the second dropdown list (beneath the Product table grid), select the Sales table.
13. Notice the ProductKey columns in each table have been selected.
The columns were automatically selected because they share the same name.
14. In the Cardinality dropdown list, notice that One To Many is selected.
15. In the Cross Filter Direction dropdown list, notice that Single is selected.
Single filter direction means that filters propagate from the “one side” to the “many
side”. In this case, it means filters applied to the Product table will propagate to
the Sales table, but not in the other direction. You will work with a bi-directional
relationship in Lab 05A.
Active relationships will propagate filters. It’s possible to mark a relationship as inactive
so filters don’t propagate. Inactive relationships can exist when there are multiple
relationship paths between tables. In which case, model calculations can use special
functions to activate them. You’ll work with an inactive relationship in Lab 05A.
18. In the Manage Relationships window, notice that the new relationship is listed, and
then click Close.
19. In the report, notice that the table visual has updated to display different values for
each product category.
20. Filters applied to the Product table now propagate to the Sales table.
21. Switch to Model view, and then notice there is now a connector between the two
tables.
22. In the diagram, notice that you can interpret the cardinality which is represented by
the 1 and ***** indicators.
Filter direction is represented by the arrow head. And, a solid line represents an active
relationship; a dashed line represents an inactive relationship.
23. Hover the cursor over the relationship to reveal the related columns.
There’s an easier way to create a relationship. In the model diagram, you can drag and
drop columns to create a new relationship.
24. To create a new relationship, from the Reseller table, drag the ResellerKey column
on to the ResellerKey column of the Sales table.
Tip: Sometime a column doesn’t want to be dragged. If this situation arises, select a
different column, and then select the column you intend to drag again, and try again.
In this lab, the SalespersonRegion and Targets tables will remain disconnected.
There’s a many-to-many relationship between salespeople and regions, you will work
this advanced scenario in the next lab.
26. In the diagram, placing the tables with the Sales table in the center, and arranging
the related tables about it.
1. In Model view, in the Fields pane, if necessary, expand the Product table.
2. To create a hierarchy, in the Fields pane, right-click the Category column, and then
select Create Hierarchy.
3. In the Properties pane (to the left of the Fields pane), in the Name box, replace the
text with Products.
4. To add the second level to the hierarchy, in the Hierarchy dropdown list,
select Subcategory.
5. To add the third level to the hierarchy, in the Hierarchy dropdown list,
select Product.
Tip: Don’t forget to click Apply Level Changes—it’s a common mistake to overlook
this step.
9. To organize columns into a display folder, in the Fields pane, first select
the Background Color Format column.
10. While pressing the Ctrl key, select the Font Color Format.
11. In the Properties pane, in the Display Folder box, enter Formatting.
12. In the Fields pane, notice that the two columns are now inside a folder.
Display folders are a great way to declutter tables—especially those that contain lots of
fields.
1. In the Region table, create a hierarchy named Regions, with the following three
levels:
o Group
o Country
o Region
3. In the Properties pane, expand the Advanced section, and then in the Data
Category dropdown list, select Country/Region.
Data categorization can provide hints to the report designer. In this case, categorizing
the column as country or region, provides more accurate information when rendering a
map visualization.
1. In the Reseller table, create a hierarchy named Resellers, with the following two
levels:
o Business Type
o Reseller
2. Create a second hierarchy named Geography, with the following four levels:
o Country-Region
o State-Province
o City
o Reseller
o Country-Region as Country/Region
o City as City
2. In the Properties pane, in the Description box, enter: Based on standard cost
4. In the Properties pane, from inside the Formatting section, slide the Thousands
Separator property to On.
6. In the Properties pane, from inside the Formatting section, slide the Decimal
Places property to 2.
7. In the Advanced group (you may need to scroll down to locate it), in the Summarize
By dropdown list, select Average.
By default, numeric columns will summarize by summing values together. This default
behavior is not suitable for a column like Unit Price, which represents a rate. Setting
the default summarization to average will produce a useful and accurate result.
In this task, you will update multiple columns in a single bulk update. You will use this
approach to hide columns, and format column values.
1. While pressing the Ctrl key, select the following 13 columns (spanning multiple
tables):
o Product | ProductKey
o Region | SalesTerritoryKey
o Reseller | ResellerKey
o Sales | EmployeeKey
o Sales | ResellerKey
o Sales | SalesOrderNumber
o Sales | SalesTerritoryKey
o Salesperson | EmployeeID
o Salesperson | EmployeeKey
o Salesperson | UPN
o SalespersonRegion | EmployeeKey
o SalespersonRegion | SalesTerritoryKey
o Targets | EmployeeID
The columns were hidden because they are either used by relationships or will be used
in row-level security configuration or calculation logic.
You will define row-level security in the next lab using the UPN column. You will use
the SalesOrderNumber in a calculation in Lab 06A.
o Sales | Cost
o Sales | Sales
4. In the Properties pane, from inside the Formatting section, set the Decimal
Places property to 0 (zero).
In this task, you will switch to Report view, and review the model interface.
o Columns, hierarchies and their levels are fields, which can be used to configure
report visuals
o Spatial fields in the Region and Reseller table are adorned with a spatial icon
o Fields adorned with the sigma symbol (Ʃ) will summarize, by default
o A tooltip appears when hovering the cursor over the Sales | Cost field
3. Expand the Sales | OrderDate field, and then notice that it reveals a date hierarchy.
The Targets | TargetMonth presents the same hierarchy. These hierarchies were not
created by you. They are created automatically. There is a problem, however. The
Adventure Works financial year commences on July 1 of each year. But, the date
hierarchy year commences on January 1 of each year.
You will now turn this automatic behavior off. In Lab 06A, you will use DAX to create a
date table, and configure it define the Adventure Works’ calendar.
4. To turn off auto/date time, click the File ribbon tab to open the backstage view.
5. At the left, select Options and Settings, and then select Options.
6. In the Options window, at the left, in the Current File group, select Data Load.
8. Click OK.
9. In the Fields pane, notice that the date hierarchies are no longer available.
In this task, you will create two quick measures to calculate profit and profit margin.
1. In the Fields pane, right-click the Sales table, and then select New Quick Measure.
2. In the Quick Measures window, in the Calculation dropdown list, from inside
the Mathematical Operations group, select Subtraction.
6. Click OK.
A quick measure creates the calculation for you. They’re easy and fast to create for
simple and common calculations. You’ll create measures without this tool using the
formula language in Lab 06A.
7. In the Fields pane, inside the Sales table, notice that new measure.
Tip: To rename a field, you can also double-click it, or select it and press F2.
10. In the Sales table, add a second quick measure, based on the following requirements:
11. Ensure the Profit Margin measure is selected, and then on the Measure
Tools contextual ribbon, set the format to Percentage, with two decimal places.
12. To test the two measures, first select the table visual on the report page.
14. Click and drag the right guide to widen the table visual.
15. Verify that the measures produce reasonable result that are correctly formatted.
Finish up
1. To remove the table, select the table (by clicking it), and then press the Delete key.
In the next lab, you will enhance the data model by configuring a many-to-many
relationship, and row-level security.
In this lab, you will create a many-to-many relationship between the Salesperson table and
the Sales table. You will also enforce row-level security to ensure that a salesperson can only
analyze sales data for their assigned region(s).
If you’re not confident you completed the previous lab successfully, you can open the
previous lab’s solution file, which is found in the D:\DA100\Lab04A\Solution folder.
In this task, you will create a many-to-many relationship between the Salesperson table and
the Sales table.
1. In Power BI Desktop, in Report view, in the Fields pane, check the follow two fields to
create a table visual:
o Salesperson | Salesperson
o Sales | Sales
The table displays sales made by each salesperson. However, there is another
relationship between salespeople and sales. Some salespeople belong to one, two, or
possibly more sales regions. In addition, sales regions can have multiple salespeople
assigned to them.
4. Use the drag-and-drop technique to create the following two model relationships:
5. Switch to Report view, and then notice that the visual has not updated—the sales
result for Michael Blythe has not changed.
6. Switch back to Model view, and then follow the relationship filter directions
(arrowhead) from the Salesperson table.
Consider this: the Salesperson table filters the Sales table. It also filters
the SalespersonRegion table, but it does not continue to propagate to
the Region table (the arrowhead is pointing the wrong way).
7. To edit the relationship between the Region and SalespersonRegion tables, double-
click the relationship.
8. In the Edit Relationship window, in the Cross Filter Direction dropdown list,
select Both.
This setting will ensure that bi-directional filtering is applied when row-level security is
being enforced. You will configure a security role in the next exercise.
12. Switch to Report view, and then notice that the sales values have not changed.
The issue now relates to the fact that there are two possible filter propagation paths
between the Salesperson and Sales tables. This ambiguity is internally resolved, based
on a “least number of tables” assessment. To be clear, you should not design models
with this type of ambiguity—it will be addressed in part in this lab, and by the next lab.
14. To force filter propagation via the bridging table, double-click the relationship
between the Salesperson and Sales tables.
15. In the Edit Relationship window, uncheck the Make This Relationship
Active checkbox.
The filter propagation is now forced to take the only active path.
17. In the diagram, notice that the inactive relationship is represented by a dashed line.
18. Switch to Report view, and then notice that the sales for Michael Blythe is now nearly
$22 million.
19. Notice also, that the sales for each salesperson—if added—would exceed the total.
While the many-to-many relationship is now working, it’s now not possible to analyze
sales made by a salesperson (the relationship is inactive). In the next lab, you’ll
introduce a calculated table that will represent salesperson for performance analysis (of
their regions).
20. Switch to Modeling view, and then in the diagram, select the Salesperson table.
21. In the Properties pane, in the Name box, replace the text with Salesperson
(Performance).
The renamed table now reflects its purpose: it is used to report and analyze the
performance of salespeople based on the sales of their assigned sales regions.
2. In Report view, add the Targets | Target field to the table visual.
3. It’s now possible to visualize sales and targets—but take care, for two reasons. First,
there is no filter on a time period, and so targets also including future target values.
Second, targets are not additive, and so the total should not be displayed. They can
either disabled by using a visual formatting property or removed by using calculation
logic. You’ll write a target measure in Lab 06B that will return BLANK when more
than one salesperson is filtered.
In this task, you will enforce row-level security to ensure a salesperson can only ever see
sales made in their assigned region(s).
3. Review the data, noticing that Michael Blythe (EmployeeKey 281) has been assigned
your Power BI account (UPN column).
Recall that Michael Blythe is assigned to three sales regions: US Northeast, US Central,
and US Southeast.
5. On the Modeling ribbon tab, from inside the Security group, click Manage Roles.
7. In the box, replace the selected text with the name of the role: Salespeople, and then
press Enter.
8. To assign a filter, for the Salesperson (Performance) table, click the ellipsis (…)
character, and then select Add Filter | [UPN].
11. To test the security role, on the Modeling ribbon tab, from inside
the Security group, click View As.
12. In the View as Roles window, check the Other User item, and then in the
corresponding box, enter your account name.
This configuration results in using the Salespeople role and impersonating the user
with your account name.
15. Notice the yellow banner above the report page, describing the test security context.
16. In the table visual, notice that only the salesperson Michael Blythe is listed.
17. To stop testing, at the right of the yellow banner, click Stop Viewing.
When the Power BI Desktop file is published to the Power BI service, there will be a
post-publication task to map security principals to the Salespeople role. You will do
this in Lab 06B.
Finish up
In the next lab, you will enhance the data model with calculations using DAX.
In this lab, you will create calculated tables, calculated columns, and simple measures using
Data Analysis Expressions (DAX).
• Create measures
If you’re not confident you completed the previous lab successfully, you can open the
previous lab’s solution file, which is found in the D:\DA100\Lab05A\Solution folder.
In this task, you will create the Salesperson table (direct relationship to Sales).
2. In the formula bar (which opens directly beneath the ribbon when creating or editing
calculations), type Salesperson =, press Shift+Enter, type 'Salesperson
(Performance)', and then press Enter.
For your convenience, all DAX definitions in this lab can be copied from
the D:\DA100\Lab06A\Assets\Snippets.txt file.
A calculated table is created by first entering the table name, followed by the equals
symbol (=), followed by a DAX formula that returns a table. The table name cannot
already exist in the data model.
The formula bar supports entering a valid DAX formula. It includes features like auto-
complete, Intellisense and color-coding, enabling you to quickly and accurately enter
the formula.
This table definition creates a copy of the Salesperson (Performance) table. It copies
the data only, however properties like visibility, formatting, etc. are not copied.
Tip: You are encouraged to enter “white space” (i.e. carriage returns and tabs) to layout
formulas in an intuitive and easy-to-read format—especially when formulas are long
and complex. To enter a carriage return, press Shift+Enter. “White space” is optional.
3. In the Fields pane, notice that the table icon is a shade of blue (denoting a calculated
table).
Calculated tables are defined by using a DAX formula which returns a table. It is
important to understand that calculated tables increase the size of the data model
because they materialize and store values. They are recomputed whenever formula
dependencies are refreshed, as will be the case in this data model when new (future)
date values are loaded into tables.
Unlike Power Query-sourced tables, calculated tables cannot be used to load data from
external data sources. They can only transform data based on what has already been
loaded into the data model.
5. Notice that the Salesperson table is available (take care, it might be hidden from
view—scroll horizontally to locate it).
9. In the Salesperson table, multi-select the following columns, and then hide them:
o EmployeeID
o EmployeeKey
o UPN
11. In the Properties pane, in the Description box, enter: Salesperson related to s sale
Recall that description appear as tooltips in the Fields pane when the user hovers their
cursor over a table or field.
12. For the Salesperson (Performance) table, set the description to: Salesperson
related to region(s)
2. On the Home ribbon tab, from inside the Calculations group, click New Table.
DAX
Date =
CALENDARAUTO(6)
This function can take a single optional argument which is the last month number of a
year. When omitted, the value is 12, meaning that December is the last month of the
year. In this case 6 is entered, meaning that June is the last month of the year.
If the column does not appear, in the Fields pane, select a different table, and then
select the Date table.
The dates shown are formatted using US regional settings (i.e. mm/dd/yyyy).
5. At the bottom-left corner, in the status bar, notice the table statistics, confirming that
1826 rows of data have been generated, which represents five full years’ data.
In this task, you will add additional columns to enable filtering and grouping by different
time periods. You will also create a calculated column to control the sort order of other
columns.
1. On the Table Tools contextual ribbon, from inside the Calculations group, click New
Column.
2. In the formula bar, type the following, and then press Enter:
DAX
Year =
A calculated column is created by first entering the column name, followed by the
equals symbol (=), followed by a DAX formula that returns a single-value result. The
column name cannot already exist in the table.
The formula uses the date’s year value but adds one to the year value when the month
is after June. This is how fiscal years at Adventure Works are calculated.
4. Use the snippets file definitions to create the following two calculated columns for
the Date table:
o Quarter
o Month
6. To create a new report page, at the bottom-left, click the plus icon.
7. To add a matrix visual to the new report page, in the Visualizations pane, select the
matrix visual type.
Tip: You can hover the cursor over each icon to reveal a tooltip describing the visual
type.
8. In the Fields pane, from inside the Date table, drag the Year field into the Rows well.
9. Drag the Month field into the Rows well, directly beneath the Year field.
10. At the top-right of the matrix visual, click the forked-double arrow icon (which will
expand all years down one level).
11. Notice that the years expand to months, and that the months are sorted
alphabetically rather than chronologically.
By default, text values sort alphabetically, numbers sort from smallest to largest, and
dates sort from earliest to latest.
12. To customize the Month field sort order, switch to Data view.
DAX
MonthKey =
14. In Data view, verify that the new column contains numeric values (e.g. 201707 for July
2017, etc.).
16. In the Fields pane, ensure that the Month field is selected (when selected, it will have
a dark gray background).
17. On the Column Tools contextual ribbon, from inside the Sort group, click Sort by
Column, and then select MonthKey.
18. In the matrix visual, notice that the months are now chronologically sorted.
In this task, you will complete the design of the Date table by hiding a column and creating
a hierarchy. You will then create relationships to the Sales and Targets tables.
3. In the Date table, create a hierarchy named Fiscal, with the following three levels:
o Year
o Quarter
o Month
o Sales | OrderDate
o Targets | TargetMonth
In this task, you will mark the Date table as a date table.
3. On the Table Tools contextual ribbon, from inside the Calendars group, click Mark
as Date Table, and then select Mark as Date Table.
4. In the Mark as Date Table window, in the Date Column dropdown list, select Date.
5. Click OK.
Power BI Desktop now understands that this table defines date (time). This is important
when relying on time intelligence calculations. You will work with time intelligence
calculations in Lab 06B.
Note that this design approach for a date table is suitable when you don’t have a date
table in your data source. If you have access to a data warehouse, it would be
appropriate to load date data from its date dimension table rather than “redefining”
date logic in your data model.
In this task, you will create simple measures. Simple measures aggregate a single column or
table.
1. In Report view, on Page 2, in the Fields pane, drag the Sales | Unit Price field into
the matrix visual.
Recall that in Lab 05A, you set the Unit Price column to summarize by Average. The
result you see in the matrix visual is the monthly average unit price.
3. Click the down-arrow for Unit Price, and then notice the available menu options.
Visible numeric columns allow report authors to decide at report design time how a
column will summarize (or not). This can result in inappropriate reporting. Some data
modelers do not like leaving things to chance, however, and choose to hide these
columns and instead expose aggregation logic defined by measures. This is the
approach you will now take in this lab.
4. To create a measure, in the Fields pane, right-click the Sales table, and then
select New Measure.
DAX
7. Notice that it produces the same result as the Unit Price column (but with different
formatting).
8. In the Values well, open the context menu for the Avg Price field, and notice that it
is not possible to change the aggregation technique.
9. Use the snippets file definitions to create the following five measures for
the Sales table:
o Median Price
o Min Price
o Max Price
o Orders
o Order Lines
The DISTINCTCOUNT() function used in the Orders measure will count orders only
once (ignoring duplicates). The COUNTROWS() function used in the Order
Lines measure operates over a table. In this case, the number of orders is calculated by
counting the distinct SalesOrderNumber column values, while the number of order
lines is simply the number of table rows (each row is a line of an order).
10. Switch to Model view, and then multi-select the four price measures: Avg Price, Max
Price, Median Price, and Min Price.
The Unit Price column is now not available to report authors. They must use the
measure you’ve added to the model. This design approach ensures that report authors
won’t inappropriately aggregate prices, for example, by summing them.
13. Multi-select the Orders and Order Lines measures, and configure the following
requirements:
14. In Report view, in the Values well of the matrix visual, for the Unit Price field, click X
to remove it.
15. Increase the size of the matrix visual to fill the page width and height.
16. Add the following five new measures to the matrix visual:
o Median Price
o Min Price
o Max Price
o Orders
o Order Lines
17. Verify that the results looks sensible and are correctly formatted.
In this task, you will create additional measures that use more complex expressions.
2. Review the table visual, noticing the total for the Target column.
Summing the target values together doesn’t make sense because salespeople targets
are set for each salesperson based on their sales region assignment(s). A target value
should only be shown when a single salesperson is filtered. You will implement a
measure now to do just that.
Tip: There are several ways to rename the column in Report view: In the Fields pane,
you can right-click the column, and then select Rename—or, double-click the column,
or press F2.
You’re about to create a measure named Target. It’s not possible to have a column and
measure in the same table, with the same name.
DAX
Target =
IF(
HASONEVALUE('Salesperson (Performance)'[Salesperson]),
SUM(Targets[TargetAmount])
The HASONEVALUE() function tests whether a single value in the Salesperson column
is filtered. When true, the expression returns the sum of target amounts (for just that
salesperson). When false, BLANK is returned.
10. Use the snippets file definitions to create the following two measures for
the Targets table:
o Variance
o Variance Margin
12. Format the Variance Margin measure as percentage with two decimal places.
13. Add the Variance and Variance Margin measures to the table visual.
While it appears all salespeople are not meeting target, remember that the measures
aren’t yet filtered by a specific time period. You’ll produce sales performance reports
that filter by a user-selected time period in Lab 07A.
15. At the top-right corner of the Fields pane, collapse and then expand open the pane.
16. Notice that the Targets table now appears at the top of the list.
Tables that comprise only visible measures are automatically listed at the top of the list.
Finish up
In the next lab, you will enhance the data model with more advanced calculations
using DAX.
In this lab, you will create measures with DAX expressions involving filter context
manipulation.
If you’re not confident you completed the previous lab successfully, you can open the
previous lab’s solution file, which is found in the D:\DA100\Lab06A\Solution folder.
In this task, you will create a matrix visual to support testing your new measures.
www.bconcepts.pt 112
DATA ANALYTICS – POWER BI LAB
4. To configure the matrix visual fields, from the Fields pane, drag the Region |
Regions hierarchy, and drop it inside the visual.
6. To expand the entire hierarchy, at the top-right of the matrix visual, click the forked-
double arrow icon twice.
Recall that the Regions hierarchy has the levels Group, Country, and Region.
7. To format the visual, beneath the Visualizations pane, select the Format pane.
10. Verify that the matrix visual has four column headers.
At Adventure Works, the sales regions are organized into groups, countries, and
regions. All countries—except the United States—have just one region, which is named
after the country. As the United States is such a large sales territory, it is divided into
five regions.
You’ll create several measures in this exercise, and then test them by adding them to
the matrix visual.
In this task, you will create several measures with DAX expressions that use the CALCULATE()
function to manipulate filter context.
For your convenience, all DAX definitions in this lab can be copied from
the D:\DA100\Lab06B\Assets\Snippets.txt file.
DAX
The CALCULATE() function is a powerful function used to manipulate the filter context.
The first argument takes an expression or a measure (a measure is just a named
expression). Subsequent arguments allow modifying the filter context.
The REMOVEFILTERS() function removes active filters. It can take either no arguments,
or a table, a column, or multiple columns as its argument.
In this formula, the measure evaluates the sum of the Sales column in a modified filter
context, which removes any filters applied to the Region table.
3. Notice that the Sales All Region measure computes the total of all region sales for
each region, country (subtotal) and group (subtotal).
This measure is yet to deliver a useful result. When the sales for a group, country, or
region is divided by this value it produces a useful ratio known as “percent of grand
total”.
4. In the Fields pane, ensure that the Sales All Region measure is selected, and then in
the formula bar, replace the measure name and formula with the following formula:
Tip: To replace the existing formula, first copy the snippet. Then, click inside the formula
bar and press Ctrl+A to select all text. Then, press Ctrl+V to paste the snippet to
overwrite the selected text. Then press Enter.
DAX
The measure has been renamed to accurately reflect the updated formula.
The DIVIDE() function divides the Sales measure (not modified by filter context) by
the Sales measure in a modified context which removes any filters applied to
the Region table.
5. In the matrix visual, notice that the measure has been renamed and that a different
values now appear for each group, country, and region.
6. Format the Sales % All Region measure as a percentage with two decimal places.
7. In the matrix visual, review the Sales % All Region measure values.
8. Add another measure to the Sales table, based on the following expression, and
format as a percentage:
DAX
Sales % Country =
DIVIDE(
SUM(Sales[Sales]),
CALCULATE(
SUM(Sales[Sales]),
REMOVEFILTERS(Region[Region])
)
)
9. Notice that the Sales % Country measure formula differs slightly from the Sales %
All Region measure formula.
The different is that the denominator modifies the filter context by removing filters on
the Region column of the Region table, not all columns of the Region table. It means
that any filters applied to the group or country columns are preserved. It will achieve a
result which represents the sales as a percentage of country.
11. Notice that only the United States’ regions produce a value which is not 100%.
Recall that only the United States has multiple regions. All other countries have a single
region which explains why they are all 100%.
12. To improve the readability of this measure in visual, overwrite the Sales %
Country measure with this improved formula.
DAX
Sales % Country =
IF(
ISINSCOPE(Region[Region]),
DIVIDE(
SUM(Sales[Sales]),
CALCULATE(
SUM(Sales[Sales]),
REMOVEFILTERS(Region[Region)
)
)
)
Embedded within the IF() function, the ISINSCOPE() function is used to test whether the
region column is the level in a hierarchy of levels. When true, the DIVIDE() function is
evaluated. The absence of a false part means that blank is returned when the region
column is not in scope.
13. Notice that the Sales % Country measure now only returns a value when a region is
in scope.
14. Add another measure to the Sales table, based on the following expression, and
format as a percentage:
DAX
Sales % Group =
DIVIDE(
SUM(Sales[Sales]),
CALCULATE(
SUM(Sales[Sales]),
REMOVEFILTERS(
Region[Region],
Region[Country]
)
)
)
16. To improve the readability of this measure in visual, overwrite the Sales %
Group measure with this improved formula.
DAX
Sales % Group =
IF(
ISINSCOPE(Region[Region])
|| ISINSCOPE(Region[Country]),
DIVIDE(
SUM(Sales[Sales]),
CALCULATE(
SUM(Sales[Sales]),
REMOVEFILTERS(
Region[Region],
Region[Country]
)
)
)
)
17. Notice that the Sales % Group measure now only returns a value when a region or
country is in scope.
18. In Model view, place the three new measures into a display folder named Ratios.
The measures added to the Sales table have modified filter context to achieve
hierarchical navigation. Notice that the pattern to achieve the calculation of a subtotal
requires removing some columns from the filter context, and to arrive at a grand total,
all columns must be removed.
1. In Report view, on Page 2, notice the matrix visual which displays various measures
with years and months grouped on the rows.
2. Add a measure to the Sales table, based on the following expression, and formatted
to zero decimal places:
DAX
Sales YTD =
TOTALYTD(SUM(Sales[Sales]), 'Date'[Date], "6-30")
3. Add the Sales field and the Sales YTD measure to the matrix visual.
Note that many Time Intelligence functions are available in DAX to support common
time filter manipulations.
1. Add an additional measure to the Sales table, based on the following expression:
DAX
The Sales YoY Growth measure formula declares a variable. Variables can be useful
for simplifying the formula logic, and more efficient when an expression needs to be
evaluated multiple times within the formula (which will be the case for the YoY growth
logic). Variables are declared by a unique name, and the measure expression must then
be output after the RETURN keyword.
3. Notice that the new measure returns blank for the first 12 months (there were no
sales recorded before fiscal year 2017).
4. Notice that the Sales YoY Growth measure value for 2017 Jul is the Sales value
for 2016 Jan.
Now that the “difficult part” of the formula has been tested, you can overwrite the
measure with the final formula which computes the growth result.
5. To complete the measure, overwrite the Sales YoY Growth measure with this
formula, formatting it as a percentage with two decimal places:
DAX
MONTH
)
)
RETURN
DIVIDE(
(SUM(Sales[Sales]) - SalesPriorYear),
SalesPriorYear
)
6. In the formula, in the RETURN clause, notice that the variable is referenced twice.
This means that July 2018 sales ($2,411,559) represents a nearly 400% (almost 4x)
improvement over the sales achieved for the prior year ($489,328).
8. In Model view, place the two new measures into a display folder named Time
Intelligence.
DAX includes many Time Intelligence functions to make it easy to implement time filter
manipulations for common business scenarios.
This exercise completes the data model development. In the next exercise, you will
publish the Power BI Desktop file to your workspace, ready for creating a report in the
next lab.
In this task, you will publish the Power BI Desktop file to Power BI.
If you’re not confident you completed this lab successfully, you should publish the
Power BI Desktop file found in the D:\DA100\Lab06B\Solution folder. In this case,
close your current Power BI Desktop file, and then open the solution file. First, perform
a data refresh (using the Refresh command on the ribbon), and then continue with the
instructions in this task.
2. To publish the file, on the Home ribbon tab, from inside the Share group,
click Publish.
It’s important that you publish it to the workspace you created in Lab 01A, and not “My
workspace”.
4. Click Select.
5. When the file has been successfully published, click Got It.
7. In the Edge, in the Power BI service, in the Navigation pane (located at the left),
review the contents of your Sales Analysis workspace.
The pubilication has added a report and a dataset. If you don’t see them, press F5 to
reload the browser, and then expand the workspace again.
The data model has been published to become a dataset. The report—used to test your
model calculations—has been added as a report. This report is not required, so you will
now delete it.
8. Hover the cursor over the Sales Analysis report, click the vertical ellipsis (…), and
then select Remove.
In the next lab, you will create a report based on the published dataset.
Finish up
In this lab, you will create a three-page report named Sales Report. You will then publish it
to Power BI, whereupon you will open and interact with the report.
• Design a report
In this task, you will create a live connection to the Sales Analysis dataset.
1. To open the Power BI Desktop, on the taskbar, click the Microsoft Power BI Desktop
shortcut.
3. Click the File ribbon tab to open the backstage view, and then select Save.
6. Click Save.
In this task, you will create a live connection to the Sales Analysis dataset.
1. To create a live connection, on the Home ribbon tab, from inside the Data group,
click Get Data, down-arrow, and then select Power BI Datasets.
3. Click Create.
4. At the bottom-right corner, in the status bar, notice that the live connection has been
established.
5. In the Fields pane, notice that the data model table are listed.
Power BI Desktop can no longer be used to develop the data model; in live connection
mode, it’s only a report authoring tool. It is possible, however, to create measures—but
they are measures that are only available within the report. You won’t add any report-
scoped measures in this lab.
Recall that you added the Salespeople role to the model in Lab 05A. Because you’re
the owner of the Power BI dataset, the roles are not enforced. This explains why, in this
lab, you can see all data.
When you share reports and dashboards to non-owners of the dataset, their account (or
a security group of which they’re a member) must be mapped to the Salespeople role.
You will configure this before sharing content in Lab 12A.
In this task, you will design the first report page. When you’ve completed the design, the
page will look like the following:
1. To rename the page, at the bottom-left, right-click Page 1, and then select Rename.
3. To add an image, on the Insert ribbon tab, from inside the Elements group,
click Image.
6. Drag the image to reposition it at the top-left corner, and also drag the guide
markers to resize it.
7. To add a slicer, first de-select the image by clicking an empty area of the report page.
8. In the Fields pane, select the Date | Year field (not the Year level of the hierarchy).
9. Notice that a table of year values has been added to the report page.
10. To convert the visual from a table to a slicer, in the Visualizations pane, select
the Slicer.
11. To convert the slicer from a list to a dropdown, at the top-right of the slicer, click the
down-arrow, and then select Dropdown.
12. Resize and reposition the slicer so it sits beneath the image, and so it is the same
width as the image.
13. In the Year slicer, select FY2020, and then collapse the dropdown list.
14. De-select the slicer by clicking an empty area of the report page.
15. Create a second slicer, based on the Region | Region field (not the Region level of
the hierarch).
16. Leave the slicer as a list, and then resize and reposition the slicer beneath
the Year slicer.
17. To format the slicer, beneath the Visualizations pane, open the Format pane.
20. In the Region slicer, notice that the first item is now Select All.
When selected, this item either selects all, or de-selects all items. It makes it easier for
report users to set the right filters.
21. De-select the slicer by clicking an empty area of the report page.
22. To add a chart to the page, in the Visualizations pane, click the Line and Stacked
Column Chart visual type.
23. Resize and reposition the visual so it sits to the right of the logo, and so it fills the
width of the report page.
o Date | Month
o Sales | Sales
25. In the visual fields pane (not the Fields pane—the visual fields pane is located
beneath the Visualizations pane), notice that the fields are assigned to the Shared
Axis and Column Values wells.
By dragging visuals into a visual, they will be added to default wells. For precision, you
can drag fields directly into the wells, as you will do now.
26. From the Fields pane, drag the Sales | Profit Margin field into the Line Values well.
The last month of the year, 2020 June, does not have any sales (yet). By default, the
visual has eliminated months with BLANK sales. You will now configure the visual to
show all months.
28. In the visual fields pane, in the Shared Axis well, for the Month field, click the down-
arrow, and then select Show Items With No Data.
30. De-select the chart by clicking an empty area of the report page.
31. To add a chart to the page, in the Visualizations pane, click the Map visual type.
32. Resize and reposition the visual so it sits beneath the column/line chart, and so it fills
half the width of the report page.
34. De-select the chart by clicking an empty area of the report page.
35. To add a chart to the page, in the Visualizations pane, click the Stacked Bar
Chart visual type.
36. Resize and reposition the visual so it fills the remaining report page space.
39. Expand the Data Colors group, and then set the Default Color property to a suitable
color (in contrast to the column/line chart).
In this task, you will design the second report page. When you’ve completed the design, the
page will look like the following:
When detailed instructions have already been provided in the labs, the lab steps will now
provide more concise instructions. If you need the detailed instructions, you can refer back to
other tasks.
4. Use the Format pane to enable the “Select All” option (in the Selection
Controls group).
5. Resize and reposition the slicer so it sits at the left side of the report page, and so it is
about half the page height.
6. Add a matrix visual, and resize and reposition it so it fills the remaining space of the
report page
8. Add the following five Sales table fields to the Values well:
o Sales
o Cost
o Profit
o Profit Margin
9. In the Filters pane (located at the left of the Visualizations pane), notice the Filter
On This Page well (you may need to scroll down).
10. From the Fields pane, drag the Product | Category field into the Filter On This
Page well.
11. Inside the filter card, at the top-right, click the arrow to collapse the card.
Fields added to the Filters pane can achieve the same result as a slicer. One difference
is they don’t take up space on the report page. Another difference is that they can be
configured for more advanced filtering requirements.
12. Add each of the following Product table fields to the Filter On This Page well,
collapsing each, directly beneath the Category card:
o Subcategory
o Product
o Color
13. To collapse the Filters pane, at the top-right of the pane, click the arrow.
In this task, you will design the third and final report page. When you’ve completed the
design, the page will look like the following:
Recall that row-level security was configured to ensure users only ever see data for their
sales regions and targets. When this report is distributed to salespeople, they will only
ever see their sales performance results.
2. To simulate the row-level security filters during report design and testing, add
the Salesperson (Performance) | Salesperson field to the Filters pane, inside
the Filters On This Page well.
3. In the filter card, scroll down the list of salespeople, and then check Michael Blythe.
You will be instructed to delete this filter before you distribute the report in an app
in Lab 12A.
4. Add a dropdown slicer based on the Date | Year field, and then resize and reposition
it so it sits at the top-left corner of the page.
6. Add a Multi-row Card visual, and then resize and reposition it so it sits to the right
of the slicer and fills the remaining width of the page.
o Sales | Sales
o Targets | Target
o Targets | Variance
o In the Data Labels group, increase the Text Size property to 28pt
9. Add a Clustered Bar Chart visual, and then resize and reposition it so it sits beneath
the multi-row card visual and fills the remaining height of the page, and half the
width of the multi-row card visual.
11. To create a copy of the visual, press Ctrl+C, and then press Ctrl+V.
12. Position the copied visual to the right of the original visual.
13. To modify the visualization type, in the Visualizations pane, select Clustered
Column Chart.
It’s now possible to see the same data expressed by two different visualization types.
This isn’t a good use of the page layout, but you will improve it in Lab 09A by
superimposing the visuals. By adding buttons to the page, you will allow the report user
to determine which of the two visuals is visible.
3. On the Home ribbon tab, from inside the Share group, click Publish.
In the next exercise, you will explore the report in the Power BI service.
In this task, you will explore the Sales Report in the Power BI service.
1. In the Edge, in the Power BI service, in the Navigation pane, review the contents of
your Sales Analysis workspace, and then click the Sales Report report.
The report publication has added a report to your workspace. If you don’t see it,
press F5 to reload the browser, and then expand the workspace again.
2. In the Regions slicer, while pressing the Ctrl key, select multiple regions.
3. In the column/line chart, select any month column to cross filter the page.
5. Notice that the bar chart is filtered and highlighted, with the bold portion of the bars
representing the filtered months.
6. Hover the cursor over the visual, and then at the top-right, click the filter icon.
The filter icon allows you to understand all filters that are applied to the visual,
including slicers and cross filters from other visual.
7. Hover the cursor over a bar, and then notice the tooltip information.
8. To undo the cross filter, in the column/line chart, click an empty area of the visual.
9. Hover the cursor over the map visual, and then at the top-right, click the In
Focus icon.
10. Hover the cursor over different segments of the pie charts to reveal tooltips.
11. To return to the report page, at the top-left, click Back to Report.
12. Hover the cursor over the map visual again, and then click the ellipsis (…), and notice
the menu options.
14. At the left, in the Pages pane, select the Profit page.
15. Notice that the Region slicer has a different selection to the Region slicer on the
Overview page.
The slicers are not synchronized. In the next lab, you will modify the report design to
ensure they sync between pages.
16. In the Filters pane (located at the right), expand a filter card, and apply some filters.
The Filters pane allows you to define more filters than could possibly fit on a page as
slicers.
17. In the matrix visual, use the plus (+) button to expand into the Fiscal hierarchy.
19. At the top-right on the menu bar, click View, and then select Full Screen.
20. Interact with the page by modifying the slicer, and cross filtering the page.
21. At the bottom-left, notice the commands to change page, navigate backwards or
forwards between pages, or to exit full screen mode.
23. To return to the workspace, in the breadcrumb trail, click your workspace name.
In this lab, you will enhance the Sales Report with advanced design features.
• Sync slicers
In this task, you will sync the Year and Region slicers.
You will continue the development of the report that you commenced designing in Lab 08A.
1. In Power BI Desktop, in the Sales Report file, on the Overview page, set
the Year slicer to FY2018.
2. Go to the My Performance page, and then notice that the Year slicer is a different
value.
4. On the View ribbon tab, from inside the Show Panes group, click Sync Slicers.
5. In the Sync Slicers pane (at the left of the Visualizations pane), in the second
column (which represents syncing), check the checkboxes for the Overview and My
Performance pages.
8. Test the sync slicers by selecting different filter options, and then verifying that the
synced slicers filter by the same options.
9. To close the Sync Slicer page, click the X located at the top-right of the pane.
In this task, you will create a new page and configure it as a drill through page.
2. Right-click the Product Details page tab, and then select Hide Page.
Report users won’t be able to go to the drill through page directly. They’ll need to
access it from visuals on other pages. You’ll learn how to drill through to the page in
the final exercise of this lab.
3. Beneath the Visualizations pane, in the Drill Through section, add the Product |
Category field to the Add Drill-Through Fields Here box.
4. To test the drill through page, in the drill through filter card, select Bikes.
The button was added automatically. It allows report users to navigate back to the page
from which they drilled through.
6. Add a Card visual to the page, and then resize and reposition it so it sits to the right
of the button and fills the remaining width of the page.
8. Configure the format options for the visual, and then turn the Category
Label property to Off.
10. Add a Table visual to the page, and then resize and reposition it so it sits beneath the
card visual and fills the remaining space on the page.
o Product | Subcategory
o Product | Color
o Sales | Quantity
o Sales | Sales
12. Configure the format options for the visual, and in the Grid section, set the Text
Size property to 20pt.
The design of the drill through page is almost complete. In the next exercise, you’ll
define conditional formatting.
In this task, you will enhance the drill through page with conditional formatting.
2. In the visual fields pane, for the Profit Margin field, click the down-arrow, and then
select Conditional Formatting | Icons.
3. In the Icons – Profit Margin window, in the Icon Layout dropdown list, select Right
of Data.
4. To delete the middle rule, at the left of the yellow triangle, click X.
The rules are as follows: display a red diamond if the profit margin value is less than 0;
otherwise if the value is great or equal to zero, display the green circle.
7. Click OK.
8. In the table visual, verify that the that the correct icons are displayed.
10. In the Background Color – Color window, in the Format By dropdown list,
select Field Value.
11. In the Based on Field dropdown list, select Product | Formatting | Background
Color Format.
13. Repeat the previous steps to configure font color conditional formatting for
the Color field, using the Product | Formatting | Font Color Format field
Recall that the background and font colors were source from the ColorFormats.csv file
in Lab 02A, and then integrated with the Product query in Lab 03A.
In this task, you will add two bookmarks, one to display each of the monthly sales/targets
visuals.
2. On the View ribbon tab, from inside the Show Panes group, click Bookmarks.
3. On the View ribbon tab, from inside the Show Panes group, click Selection.
4. In the Selection pane, beside one of the Sales and Target by Month items, to hide
the visual, click the eye icon.
7. If the visible chart is the bar chart, rename the bookmark as Bar Chart ON, otherwise
rename the bookmark as Column Chart ON.
8. In the Selection pane, toggle the visibility of the two Sales and Target by
Month items.
In other words, make the visible visual hidden, and make the hidden visual visible.
10. In the Selection pane, to make both visuals visible, simple show the hidden visual.
11. Resize and reposition both visuals so they fill the page beneath the multi-card visual,
and completely overlap one another.
Tip: To select the visual that is covered up, select it in the Selection pane.
12. In the Bookmarks pane, select each of the bookmarks, and notice that only one of
the visuals is visible.
The next stage of design is to add two buttons to the page, which will allow the report
user to select the bookmarks.
In this task, you will add two buttons, and assign bookmark actions to each.
1. On the Insert ribbon, from inside the Elements group, click Button, and then
select Blank.
3. Select the button, and the in the Visualizations pane, turn the Button Text property
to On.
4. Expand the Button Text section, and then in the Button Text box, enter Bar Chart.
6. Turn the Action property to On (located near the bottom of the list).
7. Expand the Action section, and then set the Type dropdown list to Bookmark.
9. Create a copy of the button by using copy and paste, and then configure the new
button as follows:
o In the Action section, set the Bookmark dropdown list to Column Chart ON
In the next exercise, you will explore the report in the Power BI service.
In this task, you will explore the Sales Report in the Power BI service.
1. In the Edge, in the Power BI service, open the Sales Report report.
2. To test the drill through report, in the Quantity by Category visual, right-click
the Clothing bar, and then select Drill Through | Product Details.
4. To return to the source page, at the top-left corner, click the arrow button.
6. Click each of the buttons, and then notice that a different visual is displayed.
Finish up
1. To return to the workspace, in the breadcrumb trail, click your workspace name.
5. Save the Power BI Desktop file, and then republish to the Sales Analysis workspace.
When you share the report in Lab 12A, the report will enforce row-level security.
2. To create a dashboard and pin the logo image, hover the cursor over the Adventure
Works logo.
4. In the Pin to Dashboard window, in the Dashboard Name box, enter Sales
Monitoring.
5. Click Pin.
When pinning visuals to a dashboard, they will use the current filter context. Once
pinned, the filter context cannot be changed. For time-based filters, it’s a better idea to
use a relative date slicer (or, Q&A using a relative time-based question).
8. Pin the Sales and Profit Margin by Month (column/line) visual to the Sales
Monitoring dashboard.
9. Open the Navigation pane, and then open the Sales Monitoring dashboard.
11. To resize the logo tile, drag the bottom-right corner, and resize the tile to become
one unit wide, and two units high.
Tile sizes are constrained into a rectangular shape. It’s only possible to resize into
multiples of the rectangular shape.
12. To add a tile based on a question, at the top-left of the dashboard, click Ask a
Question About Your Data.
13. You can use the Q&A feature to ask a question, and Power BI will respond will a
visual.
14. Click any one of the suggested questions beneath the Q&A box, in gray boxes.
Recall you added the Sales YTD measure in Lab 06B. This measure is Time Intelligence
expression and it requires a filter on the Date table to produce a result.
21. To pin the response to the dashboard, at the top-right corner, click Pin Visual.
22. When prompted to pin the tile to the dashboard, click Pin.
There’s a possible bug that will only allow you to pin to a new dashboard. It’s because
your Power BI session has reverted to your “My Workspace”. If this happens, do not pin
to a new dashboard. Return to your Sales Analysis workspace, open the dashboard
again, and recreate the Q&A question.
23. To return to the dashboard, at the top-left corner, click Exit Q&A.
1. Hover the cursor over the Sales YTD tile, and then at the top-right of the tile, click
the ellipsis, and then select Edit Details.
2. In the Tile Details pane (located at the right), in the Subtitle box, enter FY2020.
5. Edit the tile details for the Sales, Profit Margin tile.
6. In the Tile Details pane, in the Functionality section, check Display Last Refresh
Time.
7. Click Apply.
8. Notice that the tile describes the last refresh time (which you did when refreshing the
data model in Power BI Desktop).
Later in this lab, you’ll simulate a data refresh, and notice that the refresh time updates.
1. Hover the cursor over the Sales YTD tile, click the ellipsis, and then select Manage
Alerts.
2. In the Manage Alerts pane (located at the right), click Add Alert Rule.
3. In the Threshold box, replace the value with 35000000 (35 million).
This configuration will ensure you’re notified whenever the tile updates to a value
above 35 million.
In the next exercise, you’ll refresh the dataset. Typically, this should be done by using
scheduled refresh, and Power BI could use a gateway to connect to the SQL Server
database. However, due to constraints in the classroom setup, there is no gateway. So,
you’ll opening Power BI Desktop, perform a manual data refresh, and the upload the
file.
xxxvii. When prompted to press any key to continue, press Enter again.
3. When prompted, enter the account name of your classroom partner, and then
press Enter.
You only need to enter their account name (all characters before the @ symbol).
Choose somebody sitting near you—you will work together in pairs to complete Lab
12A, which covers sharing Power BI content.
Their account name is added so you can test the row-level security. You partner is now
Pamela Ansam-Wolfe, whose sales performance is measured by the sales of two sales
territory regions: US Northwest and US Southwest.
In this task, you will open the Sales Analysis Power BI Desktop file, perform a data refresh,
and then upload the file to your Sales Analysis workspace.
When the file was published in Lab 06B, if you weren’t confident you completed the lab
successfully you were advised to upload the solution file instead. If you uploaded the
solution file, be sure now to open the solution file again now. It’s located in
the D:\DA100\Lab06B\Solution folder.
2. On the Home ribbon, from inside the Queries group, click Refresh.
The dataset in the Power BI service now has June 2020 sales data.
7. In Edge, in the Power BI service, in your Sales Analysis workspace, notice that
the Sales Analysis report was also published.
This report was used to test the model a you developed it in Lab 05A and Lab 06A.
In this task, you will review the dashboard to notice updated sales, and that the alert was
triggered.
2. In the Sales, Profit Margin tile, in the subtitle, notice that the data was
refreshed NOW.
The alert on the Sales YTD tile should have triggered also. After a short while, the alert
should notify you that sales now exceeds the configured threshold value.
5. Verify that the Sales YTD tile displays an alert notification icon.
If you don’t see the notification, you might need to press F5 to reload the browser. If
you still don’t see the notification, wait some minutes longer.
Alert notifications appear on the dashboard tile, and can be delivered by email, and
push notifications to mobile apps including the Apple Watch8.
Tip: Use the Get Data command on the Home ribbon tab, and then select Power BI
Datasets.
You now create four report pages, and on each page you’ll work with a different visual
to analyze and explore data.
In this task, you will create a scatter chart that can be animated.
2. Add a Scatter Chart visual to the report page, and then reposition and resize it so it
fills the entire page.
The chart can be animated when a field is added to the Play Axis well.
4. In the Filters pane, add the Product | Category field to the Filters On This
Page well.
The scatter chart allows understanding the measure values simultaneously: in this case,
order quantity, sales revenue, and profit margin.
Each bubble represents a reseller business type. Changes in the bubble size reflect
increased or decreased order quantities. While horizontal movements represent
increases/decreases in sales revenue, and vertical movements represent
increases/decreases in profitability.
8. When the animation stops, click one of the bubbles to reveal its tracking over time.
9. Hover the cursor over any bubble to reveal a tooltip describing the measure values
for the reseller type at that point in time.
10. In the Filters pane, filter by Clothing only, and notice that it produces a very different
result.
In this task, you will create a forecast to determine possible future sales revenue.
2. Add a Line Chart visual to the report page, and then reposition and resize it so it fills
the entire page.
4. In the Filters pane, add the Date | Year field to the Filters On This Page well.
When forecasting over a time line, you will need at least two cycles (years) of data to
produce an accurate and stable forecast.
6. Add also the Product | Category field to the Filters On This Page well, and filter
by Bikes.
7. To add a forecast, beneath the Visualizations pane, select the Analytics pane.
If the Forecast section is not available, it’s probably because the visual hasn’t been
correctly configured. Forecasting is only available when two conditions are met: the axis
has a single field of type date, and there’s only one value field.
9. Click Add.
o Seasonality: 365
12. In the line visual, notice that the forecast has extended one month beyond the history
data.
The gray area represents the confidence. The wider the confidence, the less stable—and
therefore the less accurate—the forecast is likely to be.
When you know the length of the cycle, in this case annual, you should enter the
seasonality points. Sometimes it could be weekly (7), or monthly (30).
13. In the Filters pane, filter by Clothing only, and notice that it produces a different
result.
In this task, you will create a decomposition tree to explore the relationships between
reseller geography and profit margin.
1. Add a new page, and then rename the page to Decomposition Tree.
2. On the Insert ribbon, from inside the AI Visuals group, click Decomposition Tree.
5. In the Filters pane, add the Date | Year field to the Filters On This Page well, and
set the filter to FY2020.
6. In the decomposition tree visual, notice the root of the tree: Profit Margin at -0.94%
7. Click the plus icon, and in the context menu, select High Value.
8. Notice that the decision tree presents resellers, ordered from highest profit margin.
9. To remove the level, at the top of visual, beside the Reseller label, click X.
10. Click the plus icon again, and then expand to the Country-Region level.
12. Use the down-arrow located at the bottom of the visual for State-Province, and then
scroll to the lower profitable states.
United States is not producing profit in FY2020. New York is one state not achieving
positive profit, and it’s due to four resellers paying less than standard costs for their
goods.
In this task, you will use the Key Influencers AI visual to determine what influences
profitability within reseller business types and geography.
1. Add a new page, and then rename the page to Key Influencers.
2. On the Insert ribbon, from inside the AI Visuals group, click Key Influencers.
o Explain By: Reseller | Business Type and Reseller | Geography (the entire
hierarchy)
5. At the top-left of the visual, notice that Key Influencers is in focus, and the specific
influence is set to understand what includes profit margin to increase.
6. Review the result, which is that the city of Bothel is more likely to increase.
10. Notice that the target is now to determine segments when profit margin is likely to
be high.
11. When the visual displays the segments (as circles), click one of them to reveal
information about it.
Finish up
In this lab, you will work in pairs with a classroom partner to explore the three core methods
for sharing Power BI content.
• Share a dashboard
• Publish an app
In this task, you will assign your classroom partner’s account to the Salespeople role of your
dataset.
1. In Edge, in the Power BI service, in the Navigation pane, hover the cursor over
the Sales Analysis dataset, click the vertical ellipsis (…), and then select Security.
2. In the Row-Level Security page, at the left, notice that the Salespeople role is
selected.
3. In the Members box, commence typing the account name of your classroom
partner—when it is listed, select it.
4. Click Add.
The account of your classroom partner is now mapped to the Salespeople role. Recall
that their account is for the salesperson Pamela Ansam-Wolfe, whose sales
performance is measured by the sales of two sales territory regions: US Northwest and
US Southwest.
In this task, you will each share a dashboard, and then open the shared dashboard shared
with you.
With your classroom partner, work through all task steps together, on each of your computers.
3. In the Share Dashboard pane (located at the right), in the Grant Access To box,
commence typing the account name of your classroom partner—when it is listed,
select it.
In this task, you will each open the dashboard shared with you.
The Sales YTD tile displays a value for US Northwest and US Southwest regions only.
Sharing dashboards (and reports) is easily achieved and managed by the content
owner. Power BI provides a read-only experience to recipients. If the owner enables re-
sharing, recipients can share the content with others.
This approach should be reserved for ad hoc sharing requirements. If you need to share
many Power BI items, then publishing an app is a better option. You’ll publish your
Sales Analysis workspace as an app in the next exercise.
In this task, you will publish the contents of your Sales Analysis workspace, and then “get”
the app published by your classroom partner.
Picture 91](Linked_image_Files/PowerBI_Lab12A_image13.png)
11. In the Navigation section, notice the workspace content that will be published.
It is possible to set the order of the workspace content, and also add sections and links.
Sections are a single-level grouping of content (similar to a folder). Links are a link to
any valid web page. You won’t modify the navigation setup in this lab.
13. In the Specific Individuals or Groups box, commence typing the account name of
your classroom partner—when it is listed, select it.
The Entire Organization option may be disabled if the tenant admin has restricted it.
In this case, the Install this App Automatically option will also be disabled. If
enabled, the app could be pushed to all users. You will learn how to “get” the app in the
next task.
16. When notified that the app was successfully published, click Close.
In this task, you will “get” the app, and explore the app contents.
3. In the AppSource window, for the Sales Analysis app published by your classroom
partner, click the Get it Now link.
4. When the app is added, to open the app, click the app tile.
5. When the app opens, review the navigation pane (located at the left).
6. Notice that the first item in the navigation pane has opened.
7. In the navigation pane, expand Sales Report, and then select the Overview page.
8. Notice that Region slicer only displays two regions—the regions assigned to Pamela
Ansam-Wolfe.
10. Notice that the page displays the sales and targets for Pamela Ansam-Wolfe.
11. Open the Sales Exploration report, and then interact with the visuals on each page.
In this lab, you will use Power BI Report Builder to develop a pixel-perfect paginated report
layout that sources data from the AdventureWorksDW2020 SQL Server database. You will
create a data source and dataset, and also configure a report parameter. The report layout
will allow data to be rendered over multiple pages, and to be exported in PDF and other
formats.
• Define a dataset
In this task, you will open Power BI Report Builder to create and then save a report.
1. To open Power BI Report Builder, on the taskbar, click the Power BI Report
Builder shortcut.
2. In the Power BI Report Builder window, to create a new report, in the Getting
Started window, click Blank Report.
3. To save the report, click the File tab (located at the top-left), and then select Save.
6. Click Save.
1. In the report designer, notice the default report layout, which consists of a body
region and a report footer region.
The body contains a single textbox ready for a report title, and the report footer
contains a single textbox describing the report execution time.
The default design will render the report title once, in the body, on the first rendered
page. However, you will now modify the report design by adding a report header
region, and by moving the report title textbox into this region. This way, the report title
will repeat on every page. You will also add an image of the company logo.
2. To add a report header region, on the Insert ribbon tab, from inside the Header &
Footer group, click Header, and then select Add Header.
3. In the report designer, notice that a report header region has been added to the
report layout.
4. To select the body textbox, click the “Click to add title” textbox.
5. To move the textbox, click the four-headed arrow icon, and then drag it into the
header region to then drop it at the very top-left of the report header region.
6. To modify the report title textbox text, click inside the text box, and then enter: Sales
Order Report
To resize the textbox, you will first open the Properties pane. For fine-grained control
of location and size properties, you will need use the Properties pane.
7. On the View ribbon tab, from inside the Show/Hide group, check Properties.
8. To select the report title textbox, first click an area outside the textbox, and then click
the textbox again.
The textbox is selected when you see the border of the textbox highlighted and resizing
handles (small circles) appear on the border.
9. In the Properties pane (located at the right), scroll down the list to locate
the Position group.
The Position group allows setting exact values for the location and size of report items.
It’s important that you enter the values as directed in this lab. Pixel-perfect layout is
required to achieve the page rendering at the end of the lab.
10. Within the Position group, expand the Location group, and ensure that
the Left and Top properties are each set to 0in.
The location and size units are in inches because the regional settings of the lab virtual
machine is set to the United States. If your region uses metric measurements,
centimeters would be the default unit.
11. Within the Position group, expand the Size group, and then set the Width property
to 4.
12. To insert an image, on the Insert ribbon tab, from inside the Report Items group,
click Image.
13. To add the image to the report design, click inside the report header region, to the
right of the report title textbox.
14. In the Image Properties window, to import from an image file, click Import.
15. In the Open window, navigate to the D:\DA100\Data folder, and then select
the AdventureWorksLogo.jpg file.
18. In the report designer, notice that the image was added, and is selected.
19. To position and resize the image, in the Properties pane, configure the following
properties:
Property Value
20. To resize the report header region, first select the region by clicking a blank area of
the region.
22. Verify that the report header region contains a single textbox and image, and looks
like the following:
Tip: You can also click the disk icon located at the top-left.
You are now ready to configure the report to retrieve a database query result.
In this task, you will create a data source and dataset to retrieve a query result from
the AdventureWorksDW2020 SQL Server database.
1. In the Report Data pane (located at the left), right-click the Data Sources folder, and
then select Add Data Source.
2. In the Data Source Properties window, in the Name box, replace the text
with AdventureWorksDW2020.
3. In the Select Connection Type dropdown list, notice that Microsoft SQL Server is
selected.
5. In the Connection Properties window, in the Server Name box, enter localhost.
In the labs, you will connect to the SQL Server database by using localhost. This isn’t a
recommended practice, however, when creating your own solutions. It’s because
gateway data sources cannot resolve localhost.
7. Click OK.
9. In the Report Data pane, notice the addition of the AdventureWorksDW2020 data
source.
11. In the Dataset Properties window, in the Name box, replace the text
with SalesOrder.
13. In the Import Query window, navigate to the D:\DA100\Lab13A\Assets folder, and
then select the SalesOrder.sql file.
15. In the Query box, review the query, and be sure to scroll down to the bottom of the
query text.
It is not important that you understand the details of the query statement. It has been
designed to retrieve sales order line details. The WHERE clause includes a predicate to
restrict the query result to a single sales order. The ORDER BY clause ensures the rows
are returned by line number order.
16. Notice the use of @SalesOrderNumber in the WHERE clause, which represents a
query parameter.
A query parameter is a placeholder for a value that will be passed in at query execution
time. You will configure a report parameter to prompt the report user for a single sales
order number which will then be passed to the query parameter.
18. In the Report Data pane, notice the addition of the SalesOrder dataset and its fields.
Fields are used to configure data regions in the report layout. They were derived from
the dataset query columns.
In this task, you will configure the report parameter with a default value.
The SalesOrderNumber report parameter was added automatically when the dataset
was created. This is because the dataset query included
the @SalesOrderNumber query parameter.
3. In the Report Parameter Properties window, at the left, select the Default
Values pages.
Sales order 43659 is the value you will initially use to test the report design.
7. Click OK.
You will now complete the report header region design by adding textboxes to describe
the sales order.
In this task, you will finalize the report header region design by adding textboxes.
1. To add a textbox to the report header region, on the Insert ribbon tab, from inside
the Report Items group, click Text Box.
2. Click inside the report header region, directly beneath the report title textbox.
4. To insert a place holder, immediately after the space just entered, right-click and then
select Create Placeholder.
5. In the Placeholder Properties window, at the right of the Value dropdown list, click
the fx button.
The fx button allows entering a custom expression. This expression will be used to
return the sales order number.
9. Click OK.
11. Click a blank area of the report header region, and then select the new textbox.
Property Value
13. To format part of the textbox text, inside the new textbox, select only the Sales
Order: text.
14. On the Home ribbon tab, from inside the Font group, click the Bold command.
15. Add another textbox to the report header region, and then enter the
text Reseller: followed by a space.
Tip: You can also add a textbox by right-clicking the canvas, and then selected Insert |
Text Box.
16. After the space, insert a placeholder, and then set the value of the placeholder to use
an expression.
Property Value
21. Add a third (and last) textbox to the report header region, and then enter the
text Order Date: followed by a space.
22. After the space, insert a placeholder, and set the value of the placeholder to use an
expression based on the Datasets category, First(OrderDate) value.
23. To format the date value, in the Placeholder Properties window, select
the Number page.
Property Value
31. Verify that the report header region looks like the following:
33. To preview the report, on the Home ribbon tab, from inside the Views group,
click Run.
Running the report renders the report in HTML. As the only report parameter has a
default value, the report will run automatically.
34. Verify that the rendered report looks like the following:
35. To return to design view, on the Run ribbon tab, from inside the Views group,
click Design.
You will now add a table to the report body to display a formatted layout of the sales
order lines.
In this task, you will add a table data region to the report body.
1. On the Insert ribbon tab, from inside the Data Regions group, click Table, and then
select Insert Table.
2. To add the table, click a blank area inside the report body.
Property Value
4. The table will display five columns. By default, the table template includes only three
columns.
5. To add a column to the table, right-click inside any cell of the last column, and then
select Insert Column | Right.
7. Hover the cursor over the cell in the second row of the first column to reveal the field
picker icon.
8. Click the field picker icon, and then select the Line field.
9. Notice that the table now includes a text value in the first row (header), and a field
reference in the detail row.
o Product
o Quantity
o UnitPrice
o Amount
11. Verify that the table design looks like the following:
The table includes a header and 12 sales order line rows. There are many
o Format the table header by using a background color and bold font style
o Modify column widths to remove redundant space and to prevent long text
values from wrapping
2. Click any cell in the table to reveal the gray cell guides.
The cell guides are there to help you configure entire rows or columns.
Selecting a row or a column guide selects all cells in the row or column. Each cell is in
fact a textbox. Formatting single textbox—or a multi-selection of textboxes—can then
be achieved by using the Properties pane, or the ribbon commands.
4. In the Properties pane (or the ribbon), configure the following properties:
Property Value
DarkGreen (tip: hover the cursor over each color to reveal its
Fill | BackgroundColor
name)
Property Value
Font | Font |
Bold
FontWeight
6. In the Properties pane, set the Position | Size | Width property to 0.5.
8. While pressing the Ctrl key, multi-select the last three column header textboxes
(Quantity, Unit Price and Amount).
9. In the Properties pane (or ribbon), set the Alignment | TextAlign property to Right.
11. On the Home ribbon tab, from inside the Number group, set the last two detail (not
header) textboxes (UnitPrice and Amount) to format with a currency symbol.
12. To add a total row to the table, right-click the Quantity detail textbox, and then
select Add Total.
13. Notice that a new row, which represents the table footer, has been added, and that
the expression will evaluate the sum of Quantity values.
14. Repeat the last step to add a total for the Amount detail textbox.
15. In the first cell of the table footer row, enter the word Total.
17. Verify that the table design looks like the following:
18. To remove any trailing space after the table, hover the cursor over the dashed line
between the report body and report footer region, and then drag upwards to touch
21. Verify that the rendered report looks like the following:
22. In the Sales Order Number parameter box, replace the value with 51721.
This sales order has 72 sales order lines, and so the data will render over many pages.
24. To navigate to the second page of the report, on the Run ribbon tab, from inside
the Navigation group, click Next.
25. On page 2, notice that the table header does not appear.
You will address this issue in the next task.
26. Scroll to the bottom of the page, and then notice that the report footer displays only
the execution time.
In the next task, you will improve the footer text by appending the page number.
In this task, you will finalize the report design by ensuring multi-page reports render
appropriately.
2. To ensure the table header repeats on all pages, first select any textbox of the table.
3. In the Grouping pane (located along the bottom of the report designer), at the far
right of the Column Groups, click the down-arrow, and then select Advanced Mode.
6. In the table footer region, right-click the ExecutionTime textbox, and then
select Expression.
7. In the Expression window, in the expression box, append a space, followed by & “ |
Page “ &, to produce the following:
VB Script
11. To inject the page number value into the expression, in the Item list, double-
click PageNumber.
14. Drag the left side of the textbox to increase the width to the width of the report page.
The design of the report is now complete. Lastly, you will ensure that the page width is
set to exactly six inches, and also remove the report parameter default value.
15. To select the report body, right-click any table textbox, and then select Select | Body.
As the table fills the entire report body, this technique must be used to select the report
body.
16. In the Properties pane, ensure that the Position | Size | Width property is set to 6.
It is important the width is not greater than six inches, as rendering to print format
would break the table up across multiple pages.
17. In the Report Data pane, open the SalesOrderNumber report parameter properties.
18. On the Default Values page, select the No Default Value option.
In this task, you will view the report in print layout mode.
2. In the Sales Order Number parameter box, enter the value with 51721
3. On the Run ribbon tab, from inside the Print group, click Print Layout.
Print layout mode provides a preview of what the report will look like when printed to
the strict page size.