You are on page 1of 18

Power BI Training Day 1: Essentials

Lab Manual

Power BI Training Day 1: Essentials


Lab Manual
Table of Contents
Lab 1-1 – From Zero to Visualisation in 5 Minutes 2

Lab 1-2 – Importing and Re-shaping Data 4

Lab 1-3 – Relating Data from Different Sources 6

Lab 1-4 – Slicers and Filters 8

Lab 1-5 – Data Modelling 101 10

Lab 1-6 – Calculated Columns and Measures 14

Power BI Training Day 1: Essentials


Lab Manual
Lab 1-1 – From Zero to Visualisation in 5 Minutes
1. Open Power BI Desktop.
2. Click “Get data”.
3. Select “Excel” and click “Connect”.
4. ..\Source Data\Apparel Sales\Apparel Wholesale Report.xlsx
5. Select “SalesData” tab and click “Load”.
6. Under the “Visualizations” window, select “Clustered Column Chart” to create a new empty visual.
7. Under the “Field List”, tick the box next to the “Units” field.

This should place the “Units” field into the “Value” box for the column chart and a single column should appear that
is currently showing the total of the “Units” field for all of the imported data.

8. Under the “Field List”, tick the box next to the “ProductCategory” field.

This should place the “ProductCategory” field into the “Axis” box for the column chart and the chart should now be
showing the total of the “Units” field split by each of the values in the “ProductCategory”.

9. Click on a blank area of the canvas to deselect the Units by ProductCategory column chart.
10. Under the “Visualizations” window, select “Stacked bar chart” to create a new empty visual.
11. Under the “Field List”, tick the box next to the “SalesAmount” field.
12. Under the “Field List”, tick the box next to the “SalesPerson” field.
13. Hover over the bars in the chart to display the tool-tip.

Observe how the number isn’t formatted clearly as it represents a monetary amount but isn’t obvious.

14. In “Field List” click the name of the entry “SalesAmount” (not the tick-box) – this will select the field for
formatting.
15. Under “Modelling” tab change format to “Currency general”. Set 2 decimal places.

Observe that the tool-tip has changed.

16. Click on a blank area of the canvas and put a tick in the “PickupDepotLocation” box. The values should
appear as table displaying the location text.
17. Delete the table that was created by clicking on the small "…" (More Options) button in the top-right of the
table visual and selecting "Remove". You can also click the "DELETE" key on your keyboard. We’re going
to create a map instead.
18. In “Field List” click to select “PickupDepotLocation” for formatting.
19. Under the “Modelling” tab change “Data Category” to “Place”. Observe how an icon appears next to the
field in the “Field List” to indicate change.
20. Put a tick in the “PickupDepotLocation” box and notice that the visual created is a map.
21. In the “Field List” tick “Units” to make the size of the bubbles reflect the total units sold.
22. Ensuring the map is selected, under the “Format” gutter increase the size of the Bubbles to 30.
23. Create a new empty “Line and stacked column chart” visual.
24. In “Field List” tick “TransactionDate” and “SalesAmount”. Observe how the chart axis is showing dates but
not automatically rolling up to Date Hierarchy.
25. In “Field List” select “TransactionDate”. Under the “Modelling” tab, observe how Data type is “Text”.

The TransactionDate field has been imported from the source Excel file but has not been automatically identified as
a “Datetime” data type. We can change the data type here to “Datetime” however this doesn’t handle errors well.
We will fix it in the query instead.

26. On the “Home” tab, click “Edit Queries”.

Power BI Training Day 1: Essentials


Lab Manual
27. In the “SalesData” query observe how the “TransactionDate” column is still set to Data type “Any”.

Any fields with a Data type of “Any” will be interpreted as a “Text” value in the Power BI visualisation layer.

28. On the “Home” tab, change the Data type to “Date/Time” and click “Close and Apply”.

Observe how the chart is now displaying the data as a date (axis label shows Month & Year). However, it is too
detailed for what we want.

29. In the Fields gutter, under the Shared axis for the chart, click the arrow next to “TransactionDate” and
select “Date Hierarchy”.

Observe how the Shared axis has changed to show the Year > Quarter > Month > Day hierarchy and that the chart
is automatically rolling up the “SalesAmount” to the Year level.

30. Expand the chart down using the “Expand all down one level in the hierarchy” button. This will now be at
the year/quarter level.
31. Expand down again to arrive at the year/quarter/month level.
32. Drag the “Units” field from the “Field List” onto the “Line values” box in the Fields gutter for the chart.
33. Select the “Units by ProductCategory” chart on the canvas that was created in the first step of this lab.
34. Drag the “ProductName” field from the “Field List” and drop it just under the “ProductCategory” field in the
Axis. This will create a drill-down pathway.
35. Click on the “Focus mode” box on the pop-up header frame of the “Units by ProductCategory” chart (it
sometimes appears below the visualisation if it is at the top of the canvas). This will maximise the view on
the chart.
36. Click on the “Go to the next level in the hierarchy” drill down button. Observe how this affects the data
displayed.
37. Click on the “Drill up” button to return to the ProductCategory level.
38. Click on the “Expand all down one level in the hierarchy” drill down button. Observe how this affects the
data displayed.
39. Click on the “Drill up” button to return to the ProductCategory level.
40. Click on the “Click to turn on Drill Down” button and then click on one of the ProductCategory columns.
Observe how this drills down to the next level but only for the ProductCategory selected.
41. Click on the “Drill up” button to return to the ProductCategory level.
42. Click again on the activated Drill Down button to deactive Drill Down mode.

Explore the options under the “More options” button (Export data, Show data, sorting).

43. If necessary, click the “Back to Report” button to return from Focus Mode to the full report view.
44. Add a text box at the top of the report with the text “Sales Overview” and format as desired.
45. Select the “Units by ProductCategory” chart and, under the “Format” gutter, explore the options for “Data
colors”, “Title”. Notice how there are different formatting options for the different types of visuals (eg Map
vs column/bar chart). Format your visuals as desired.
46. Explore what happens to other charts when you click on various chart elements (cross filtering).
47. Rename the report page “Sales Overview”
48. Save the Power BI report to your training folder called “Sales Report [YOUR_NAME]” – replacing
[YOUR_NAME] with your first name
49. Close Power BI Desktop

Power BI Training Day 1: Essentials


Lab Manual
Lab 1-2 – Importing and Re-shaping Data
1. Open Power BI Desktop.
2. Get data -> Excel -> ..\Source Data\Airline Analytics\Fuel Uplift Budget - 2016.xlsx
3. Select “FuelUplift_Budget” tab and observe the preview showing formatting issues that need to be
handled.
4. Click “Edit” to enter the source data query editor.

Observe that the source Excel report has a number of header rows that need to be removed and the format of the
data is in a cross-tab or pivoted layout that doesn’t lend itself to analysis – these are what we need to correct.

5. On the “Home” tab, click the “Remove Rows” button and select “Remove Top Rows”.
6. Enter 3 in the box and click “OK” to remove the top 3 rows.

Observe how a new entry has appeared under the “Applied Steps” called “Removed Top Rows”.

7. Click on the “Changed Type” step and notice how the data preview window changes to show the data as it
would be at the end of that step.
8. Click back on the “Removed Top Rows” step.
9. On the “Home” tab, click on the “Use First Row as Headers” box and observe how the fields are now
named what was previously the first row.

The data is still in a cross-tab or pivoted format, we want to unpivot the data so that we have one row per cost
centre per month.

10. Right-click on the “Cost Centre” column and select “Unpivot Other Columns”

We only want the Cost Centre number not the full text that is in the report currently.

11. Select the “Cost Centre” column.


12. On the “Transform” tab, click “Extract” button and select “Text After Delimiter”.
13. Enter the text “ - “ (a hyphen with a blank space either side) and click “OK”.

Observe that the Cost Centre column now only contains the numeric Cost Centre.

14. Select the “Attribute” column.


15. On the “Transform” tab, click “Date” button and select “Parse”.

The “Attribute” column is now a date value and has been changed to a “Date” data type.

16. Double-click on the “Attribute” column and rename it to “Budget Date”.


17. Double-click on the “Value” column and rename it to “Fuel Uplift Budget Amount”.
18. Click on the data type icon next to the “Fuel Uplift Budget Amount” column and if it is not already, change
the data type to “Whole Number”.
19. Click on the data type icon next to the “Cost Centre” column and select “Whole Number” to change the
data type.

Observe the number of entries in the Applied Steps window.

20. On the “Home” tab, click “Close and Apply”. This will then connect to the specified data source and run
through the defined Applied Steps to load the data into Power BI.

Now that we have our budget data in a format for reporting, let’s create a few quick visualisations using it.

Power BI Training Day 1: Essentials


Lab Manual
21. Create a line chart with “Budget Date” on the Axis and “Fuel Uplift Budget Amount” as the Values.
22. Expand the line chart down to the month level to display the budget amount over the year for all cost
centres.
23. For clarity, change the formatting for the “Fuel Uplift Budget Amount” field on the “Modelling” tab to show
the Thousands separator (looks like a comma icon).
24. Start a blank “Table” visual.
25. In the “Field List”, tick the “Cost Centre” and “Fuel Uplift Budget Amount” fields.

Notice how the Cost Centre field has been aggregated. This is not the expected behaviour but Power BI sees that
the field is numeric and by default assumes that it makes sense to aggregate it for analysis. Let’s change that.

26. Under the Values for the table visual, click on the down-arrow on the “Cost Centre” field and select “Don’t
Summarize”.

This has changed it for this particular visual but as we would never want to aggregate the Cost Centre field let’s
change it in the data model.

27. In the “Field List”, select the “Cost Centre” field.


28. Under the “Modelling” tab, change the “Default Summarization” to “Don’t Summarize”.
29. Click on the column header on the table visual to sort by “Fuel Uplift Budget Amount” descending so that
the Cost Centres with the largest yearly budget are at the top.
30. Click on the top Cost Centres in the table to explore how the yearly budget amount is distributed across
the months in the year.
31. Save this Power BI report to your training folder called “Lab 1-2 - Airline Analytics [YOUR_NAME]” –
replacing [YOUR_NAME] with your first name.
32. Close Power BI Desktop.

Power BI Training Day 1: Essentials


Lab Manual
Lab 1-3 – Relating Data from Different Sources
1. Copy your Lab 1-2 – Airline Analytics [YOUR_NAME] Power BI report and give it the name “Lab 1-3 –
Airline Analytics [YOUR_NAME]”.
2. Open “Lab 1-3 – Airline Analytics [YOUR_NAME]” to start up Power BI Desktop.
3. Click on “Get Data”, choose “Text/CSV” from the list of available source types and click “Connect”.
4. Navigate to the ‘Source Data” > “Airline Analytics” folder and select the “CostCentre” CSV file.

Observe the data preview and the options to the top of the screen to adjust the default options for scanning the
file.

5. Click “Edit” to enter the source data query editor.

Observe the steps that have automatically been applied (Promoted Headers, Changed Type).

6. Click “Close and Apply” to load the data into Power BI.

Observe that the new table has now appeared in the “Field List”.

7. Click on the Relationship view button to view how the data tables are related.

Observe how Power BI has automatically related these two tables. Notice the “1” on the “CostCentre” side and the
“*” on the “FuelUplift_Budget” denoting the one-to-many relationship. Also notice the small arrow on the link
pointing from “Cost Centre” to “FuelUplift_Budget” denoting the direction of the relationship.

8. Hover over the link and see how it highlights the fields in the relationship.

NOTE: The relationship should be between the “FuelUplift_Budget[CostCentre]” and “CostCentre[Cost Centre ID]”
fields. If not, you may need to delete the relationship and recreate it. Please ask your trainer to assist if this is the
case.

The relationship appears to be as required so click on the Report view button to return to the visuals.

9. Click on a blank area of the canvas and then tick “Fuel Uplift Budget Amount” from the “FuelUplift_Budget”
table.
10. Tick “Cost Centre Lvl 1” from the “CostCentre” table.

You are now analysing the data from the “Fuel Uplift Budget – 2016” Excel document using the reference data from
the “CostCentre” CSV file.

11. Click on the two columns in the chart to see how the cross-filtering affects the existing visual elements.
12. Create a drill-down pathway in the chart by dragging the “Cost Centre Lvl 2” and “Cost Centre Lvl 3” fields
in under the existing “Cost Centre Lvl 1” field in the Axis.
13. Click the “Click to turn on Drill Down” button and drill down the chart to the “Cost Centre Lvl 3” level.
14. Un-click the “Click to turn on Drill Down” button to re-enable the cross-filtering and explore how clicking
on various columns affects the existing visual elements.
15. Select the table visual and delete the “Cost Centre” field from the Values.
16. Tick the “Cost Centre” field under the “CostCentre” table to show the full name of the cost centre.
17. Drag the “Cost Centre” field to the top of the list in the Values to position it as the left-most column in the
table.

Power BI Training Day 1: Essentials


Lab Manual
Now that we have incorporated the “CostCentre” reference data the numeric “Cost Centre” field under the
“FuelUplift_Budget table is unnecessary. It is a technical field that has no business value for analysis. Let’s tidy up
our data model to ensure there is no confusion.

18. Right-click on the “Cost Centre” field under the “FuelUplift_Budget table and select “Hide”.

The field disappears from the field list but it still exists in our data model because it is still required to form the
relationship between the two tables.

19. Right-click on the “Cost Centre ID” field under the “Cost Centre” table and select “Hide”.

The data model is now displaying the essential information for analysis with some visuals incorporating data from
two separate sources. Now let’s explore what happens when you remove the relationship.

20. On the “Home” tab, click on “Manage Relationships”.

Observe how you can create new relationships, auto-detect new relationships, edit existing relationships or delete
relationships using this dialog.

21. Click the “Delete” button to remove the existing relationship.


22. Read the pop-up dialog warning that deleting a relationship could break existing visuals and then click
“Delete”.
23. Click “Close” to exit the “Manage Relationships” dialog.
24. Hover over the columns in the chart and observe that the “Fuel Uplift Budget Amount” is the same for
both columns.
25. Drill-down into one of the columns and observe that the “Fuel Uplift Budget Amount” is the same for all
columns.
26. Observe that the “Fuel Uplift Budget Amount” is the same for all rows in the table.
27. Try to use the chart to cross-filter the line chart.

Now that the relationship has been removed there is no way for Power BI to know how to use the values in the
“CostCentre” table to filter the “Fuel Uplift Budget Amount” in the “FuelUplift_Budget” table. Because there is no
context to work with, Power BI assumes all of the rows in the “FuelUplift_Budget” table should be used for any and
all values in the “CostCentre” table. The result is that the total budget amount is displayed. Let’s recreate the
relationship.

28. On the “Home” tab, click on “Manage Relationships”.


29. Click the “New…” button to manually create a new relationship.
30. Choose the “FuelUplift_Budget” table in the top drop-down.
31. Choose the “CostCentre” table in the bottom drop-down.
32. Click to select the “Cost Centre” column under the “FuelUplift_Budget” table.
33. Click to select the “Cost Centre ID” column under the ‘CostCentre” table.
34. Click “OK” to close the new relationship dialog and then click “Close” to apply the changes to the
relationships.

Observe that the visuals in the report are now working correctly.

35. Save your Power BI report which should be called “Lab 1-3 – Airline Analytics [YOUR_NAME]”.
36. Close Power BI Desktop.

Power BI Training Day 1: Essentials


Lab Manual
Lab 1-4 – Slicers and Filters
1. Copy your “Lab 1-3 – Airline Analytics [YOUR_NAME]” Power BI report and give it the name “Lab 1-4 –
Airline Analytics [YOUR_NAME]”.
2. Open “Lab 1-4 – Airline Analytics [YOUR_NAME]” to start up Power BI Desktop.
3. Click on a blank area of the canvas and click the “Slicer” visual to start a new blank visual element.
4. Tick the “Cost Centre Lvl 1” field under the “CostCentre” table.
5. In the slicer, tick the “0 - Head Office” box and observe how all of the chart elements update to reflect that
selection.
6. In the slicer, tick the “1 - Regional Offices” box and observe how the selection of “0 - Head Office" is
removed and all of the chart elements update to reflect the new selection.
7. As you hover over the slicer, notice the small eraser button that appears at the top of the slicer – click it to
remove any selected values.
8. To select multiple values, hold down the “CTRL” key and tick “0 - Head Office” and “1 - Regional Offices”.
9. Click the down-arrow button that appears at the top of the slicer and choose “Dropdown”.

Observe how this collapses the list of available options and saves space on a canvas.

10. Click the down-arrow button at the top of the slicer and return the slicer to “List”.
11. Under the Format gutter, under the “General” section, change the “Orientation” to “Horizontal”.

You may need to resize the slicer to observe the full list of options.

12. Under the Format gutter, under the “Selection Controls” section, slide the “Multi-select with CTRL” slider to
“Off”.

Explore what happens when you select different values in the slicer now.

13. Click on a blank area of the canvas and click the “Slicer” visual to start a new blank visual element.

14. Tick the “Budget Date” field under the “FuelUplift_Budget” table.

Observe how a date value displays with a slider. Explore the options available under the down-arrow button at the
top of the slicer that give options to adjust how the slider works.

15. Select the column chart showing “Fuel Uplift Budget Amount by Cost Centre”.
16. Remove “Cost Centre Lvl 1” from the fields under the Axis.

The slicer continues to filter all chart elements until such time that it is changed. This differs from cross-filtering,
where the selection on one visual is lost as soon as you click on another visual element. Let’s look at filters.

17. Select the column chart showing “Fuel Uplift Budget Amount by Cost Centre”.
18. Under the “Home” tab, click “Copy” (or press CTRL-C).
19. Under the “Home” tab, click “Paste” (or press CTRL-V).
20. This will create a copy of the chart – resize and move the two charts so they fit on to the canvas.
21. Select your new copy of the chart.
22. Remove “Cost Centre Lvl 3” from the fields under the Axis.
23. From the “Field List”, drag the “Cost Centre Lvl 3” field and drop it into the “Visual level filters” box.

Observe how the default view is showing a list of all the available values in that field that can be selected.

24. Tick the box for “0000 - Salaries”. Notice how just the individual chart is filtered using that selection.
25. Un-tick the box for “0000 – Salaries” – we want to filter this chart to all “salary” cost centres.

Power BI Training Day 1: Essentials


Lab Manual
26. Change the “Filter Type” drop-down to “Advanced filtering”.
27. Click the “Show items when the value:” drop-down and review some of the options that can be applied.
28. Keep the selection as “contains” and in the box underneath type in “salaries” (without the quotes).
29. Click the “Apply filter” box at the bottom of the window.

We have now created a column chart showing the “Fuel Uplift Budget Amount” by the “Cost Centre Lvl 2” where
the “Cost Centre Lvl 3” is attributed to “salaries”. The chart title is a little misleading now. Let’s quickly correct that.

30. Select the chart that is filtered by “salaries”.


31. Under the Format gutter, under the “Title” section, change the “Title Text” to “Fuel Uplift Budget Amount
for Salaries by Cost Centre Lvl 2”.

We’ll now create one more visual level filter using the Top N capability.

32. Select the table that is showing “Cost Centre” and “Fuel Uplift Budget Amount”.
33. Under the “Visual level filters”, click the down-arrow next to “Cost Centre”.
34. Change the “Filter Type” to “Top N”.
35. Under “Show items:”, leave the default of “Top” and in the box next door enter “5” (without the quotes).
36. From the “Field List”, drag the “Fuel Uplift Budget Amount” field and drop it into the “By value” box.
37. Click the “Apply filter” box at the bottom of the window.

Observe that the table now shows the 5 “Cost Centre” items with the largest “Fuel Uplift Budget Amount” based on
the current selection. Explore what happens to the list of cost centres as you adjust slicer selections or cross-filter
using other visual elements.

38. Save your Power BI report which should be called “Lab 1-4 – Airline Analytics [YOUR_NAME]”.
39. Close Power BI Desktop.

Power BI Training Day 1: Essentials


Lab Manual
Lab 1-5 – Data Modelling 101
1. Copy your “Sales Report [YOUR_NAME]” Power BI Report from Lab 1-1 and call it “Sales and Delivery
Report [YOUR_NAME]”.
2. Open “Sales and Delivery Report [YOUR_NAME]”.
3. On the “Home” tab, click “Get Data” and select “Excel”.
4. Navigate to “..\Source Data\Apparel Sales\WarehouseDeliveryReport – 2016” and load in the “Deliveries”
worksheet.
5. Click the “Relationship” view button.
6. Try to create a relationship between the “ProductID” field in the “SalesData” table and the “ProductID” field
in the “Deliveries” table.

Notice the warning that appears at the bottom of the dialog. Power BI supports many-to-many style relationships
(where neither side of the relationship contains unique values) however it is an advanced modelling technique that
should be avoided unless the author is fully aware of the implications.

To solve this, we’re going to need to re-shape the data using data modelling techniques.

7. Click “Cancel” on the “Create relationship” dialog box.


8. On the “Home” tab, click on “Edit Queries”.
9. Right-click on the “SalesData” query in the “Queries” pane and select “Duplicate”.

This will create a copy of the original query called “SalesData (2)”.

10. Hold down the SHIFT key and select the following columns:
 ProductID
 ProductName
 ProductCategory
11. On the “Home” tab, click the down-arrow under the “Remove Columns” button and select “Remove Other
Columns”.
12. Click on the “Remove Rows” button and select “Remove Duplicates”.

This will result in a table with one row per ProductID.

13. In the top-right of the window, change the name of the query to “Product”.
14. Click “Close and Apply”.

The new “Product” table should get loaded in and because the data types and field names are compatible, Power
BI has automatically detected a relationship between the “SalesData” and “Deliveries” tables. Using star schema
methodology, the “Product” table is a dimension and the “SalesData” and “Deliveries” tables are fact tables. Let’s
test our new data model.

15. Click the “Report” view button to return to the visuals.


16. Click the + sign at the bottom of the report to create a new blank page.
17. Start a new blank Clustered Column Chart visual.
18. Tick “ProductCategory” from the “Product” table, “Units” from the “SalesData” table and “DeliveredUnits”
from the “Deliveries” table.

We’re now using our Product dimension to “slice and dice” our data for analysis.

19. Start a new blank line chart.

Power BI Training Day 1: Essentials


Lab Manual
20. Tick “TransactionDate” from the “SalesData” table, “Units” from the “SalesData” table and then expand
down to the month level.
21. Tick the “DeliveredUnits” from the “Deliveries” table.

Observe how the line chart looks wrong. Hover over the lines and notice that the “DeliveredUnits” value is the
same across all months. This is because the only relationship between the “SalesData” table and the “Deliveries”
table is via the “Product” dimension – Power BI has no knowledge of how to slice the “DeliveredUnits” table using
the “TransactionDate” field from the “SalesData”.

Let’s add in another dimension to resolve this and assist in our reporting.

22. Click on “Get Data” and select “Excel”.


23. Navigate to “..\Source Data\Apparel Sales\Date.xlsx”, select the “Date” worksheet and click “Edit”
24. In the “Date” query, confirm that the data type of the “Date” column is “Date”.
25. In the “Deliveries” query, confirm that the data type of the “DeliveryDate” column is “Date”.
26. In the “SalesData” query, change the data type of the “TransactionDate” column to “Date”.
27. Read the Change Column Dialog box and understand that we are seeing this prompt because we are
attempting to change the type of a column whilst still selected on an existing step that changes the data
type for that column. In this instance we will select “Replace current” but we could choose to add a new
step if necessary.
28. Click Close and Apply to load the data.
29. Click the “Relationships” view button to visualise the current relationships between the tables.

An easy way to create a simple relationship between new tables is to drag and drop the fields.

30. Under the “Deliveries” table, click and drag the “DeliveryDate” field and drop it on top of the “Date” field in
the “Date” table.
31. Under the “SalesData” table, click and drag the “TransactionDate” field and drop it on top of the “Date”
field in the “Date” table.

This should now have created two new relationships to the Date dimension that will allow us to better understand
our sales and delivery data.

32. Click the “Report” view button to return to the visuals.


33. Remove the “TransactionDate” field from the line chart Axis and replace it with the “Date” field from the
“Date” table.
34. Expand the line chart down to the month level.

Let’s use some of the other attributes in our Date dimension to chart things differently.

35. Remove the “Date” field from the line chart Axis and replace it with the “Calendar Month” field from the
“Date” table.
36. Under the “…” (More options) for the line chart, select to
o Sort by “Calendar Month”
o Sort ascending

Observe that the data has been charted using the “Calendar Month” field but the months are not in the correct
order. Power BI only knows that this is a text value – it doesn’t know it actually represents something that has a
specific order. We’re going to need to tell Power BI how to order these values.

37. In the “Field List”, click to select the “Calendar Month” field.
38. On the “Modelling” tab, click the “Sort by Column” button and select “Calendar Month No”.

Observe how the Calendar Month values along the line chart axis are now ordered correctly.

Power BI Training Day 1: Essentials


Lab Manual
39. Right-click on the “Calendar Month No” field under the “Date” table and select “Hide”.
40. Remove the “Calendar Month” field from the line chart Axis and replace it with the “Calendar Month Year”
field from the “Date” table.
41. Sort the chart by the “Calender Month” field, in ascending order.

Again, notice that the “Calendar Month Year” values along the axis are not sorted correctly.

42. Click the “Data” view button to observe the data in the tables that have been imported.
43. Select the “Date” table under the “Field List”.
44. Select the “Calendar Month Year” field.
45. On the “Modelling” tab, click the “Sort by Column” button and choose “Date”.

Observe the error message that appears. You can’t sort by a column that has more than one value for the same
entry in the table you are trying to sort. To ensure that a column exists that meets this criteria it may be necessary
to build a new column when importing the data. However, in this case, one already exists in the dataset.

46. Click “Close” on the error message box.


47. Click the “Sort by Column” button again and choose “Calendar Month Year Order”.
48. Click the “Report” view button and observe that the “Calendar Month Year” values along the axis are now
ordered correctly.
49. Hide the “Calendar Month Year Order” field under the “Date” table.

There are other fields in the date table that should also be ordered but we will leave them as they are for now.

Hover over the charts and observe how the “Units” and “DeliveredUnits” fields are hard to read at a glance. Let’s
format them in the data model so that any time they are used they show consistently.

50. Click to select the “DeliveredUnits” field in the “Field List”.


51. On the “Modelling” tab, click on the thousands separator button (looks like a comma).
52. Double-click on the “DeliveredUnits” field in the “Field List” and rename it to “Delivered Units” (include a
space).

Observe how this has been updated across all of the visual elements and how a small change can increase
readability.

53. In the “Field List”, click on the small ellipsis (…) to the right of the “Deliveries” table and select “Edit Query”.

This is another way to get directly to the data load query you want.

Observe how a new step has been applied that reflects the renaming of the column.

54. Click “Close and Apply” to exit the query window.


55. Apply the same formatting changes to the “Units” field in the “SalesData” table.
56. Rename the “SalesData” table to “Sales”.

Now that we have a “Product” and “Date” dimension we should hide the unnecessary columns in the “Sales” table.

57. Hide the following columns in the “Sales” table:


 ProductID
 ProductCategory
 ProductName
 TransactionDate
58. Rename this Power BI report page to “Delivery vs Demand”.
59. Click to the “Sales Overview” page of the report.

Power BI Training Day 1: Essentials


Lab Manual
Observe how none of the visuals that were created previously have stopped working even though we have now
hidden the fields that were used to create them. However, it could be confusing or cause problems later so it
would be best to replace them with the same fields from the dimension tables. This can be completed at a later
date.

60. Click to the “Delivery vs Demand” page of the report.


61. Create a matrix visual element:
 Rows: “ProductCategory”, “ProductName” (you may need to drag the “ProductName” column in
rather than tick the box)
 Values: “Delivered Units”, “Units”, “UnitCost”
 Explore the drill-down options for a matrix
62. Create a treemap visual element:
 Group: “ProductName”
 Values: “Delivered Units”
63. Explore cross-filtering using the visual elements.

Review the “Sales” table and identify any other potential areas where your new data modelling knowledge could be
used to improve your data model.

64. Save your report which should be called “Sales and Delivery Report [YOUR_NAME]”.
65. Close Power BI Desktop.

Power BI Training Day 1: Essentials


Lab Manual
Lab 1-6 – Calculated Columns and Measures
1. Copy your “Sales and Delivery Report [YOUR_NAME]” Power BI Report and call it “Sales and Delivery
Report – Final [YOUR_NAME]”.
2. Open “Sales and Delivery Report – Final [YOUR_NAME]”.
3. Click to select the “Sales” table.
4. On the “Modelling” tab, click the “New Column” button.
5. In the formula box that appears at the top of the canvas enter the following DAX formula then press
<ENTER>:

Cost Amount = Sales[UnitCost] * Sales[Units]

6. Create a new table visual and add the following fields:


 Product[ProductName]
 Product[ProductCategory]
 Sales[SalesAmount]
 Sales[CostAmount]
7. Change the formatting on the “SalesAmount” and “CostAmount” fields if necessary.
8. Filter the “ProductName” field using a TOP N filter to only show the top 5 products by “SalesAmount”.
9. Click on the “SalesAmount” column heading to order the content in decreasing value.
10. In the “Field List”, ensure the “Sales” table is selected and add another new column.
11. In the formula box that appears at the top of the canvas enter the following DAX formula then press
<ENTER>:

Profit = Sales[SalesAmount] - Sales[Cost Amount]

12. Add the “Profit” field to the same table on the report and format the field appropriately.

Let’s use our new profit field to add some extra information to our existing chart elements.

13. On the “Sales Overview” page, click to select the column chart showing Units by ProductCategory.
14. Under the “Formatting” gutter, expand the “Data colors” section.
15. Click on the three dots that appear when hovering over the “Default color” title and select “Conditional
formatting”.
16. Click on the “Based on field” drop-down and select the Sales[Profit] field.
17. Click and drag the “Profit” field and drop it on the “Color saturation” box in the field gutter.

Observe how this has changed the saturation of the columns based on profit for each category. The number of
units sold doesn’t necessarily equate to the most profitable category.

18. To assist in understanding why the columns are coloured differently, navigate to the Fields gutter and drag
the Sales[Profit] field to the “Tooltips” box.
19. Hover over the chart to see the [Profit] values shown on the columns.
20. Return to the “Format” gutter and explore the options under the “Data colors” section to find a setting that
is the most effective.

By using two related metrics it is possible to provide greater understanding of the data without taking up any more
space.

21. Select the SalesAmount by SalesPerson bar chart and apply the same conditional formatting rules as
above.

Power BI Training Day 1: Essentials


Lab Manual
Observe how this doesn’t provide any more substantial understanding as the assumption is that a sales person with
the greatest SalesAmount is probably likely to also have a high profit. As a result, the saturation falls in line with the
lengths of the bars. Let’s create a more useful metric to highlight sales people who are generating more profit.

22. Click on the “Data” view button.


23. Click to select the “Sales” table and locate the calculated columns “Cost Amount” and “Profit”.
24. Create a new column with the following formula:

Profit Percentage = Sales[Profit] / Sales[Cost Amount]

25. Format the “Profit Percentage” column as a “Percentage” with 1 decimal place.
26. Click on the “Report” tab to return to the visuals.
27. Change the conditional formatting for the sales person bar chart and to use the “Profit Percentage” field.

Observe how it appears something isn’t working as expected.

28. Add the “Profit Percentage” field to the tooltips for the sales person bar chart.
29. Hover over one of the bars in the chart and look at the “Profit Percentage” figure.

Why is it showing percentages in the ‘000s? The values in the “Profit Percentage” column are correct on a line-by-
line basis but the bar chart is automatically aggregating the figures for each “SalesPerson”. This is not correct and,
in fact, the current “Profit Percentage” calculation would only be correct if and only if the data was displayed at an
individual transaction level.

We need a calculation that works dynamically based on what fields and filters are being used – enter Measures!

30. Under the formatting options for “Data colors”, click the “Revert to default” to reset the conditional
formatting.
31. Delete the “Profit Percentage” field from the “Sales” table.
32. In the “Field List”, click to select the “Sales” table.
33. On the “Modelling” tab, click “New Measure”.
34. Enter the following formula and press <ENTER>:

Profit % = Sales[Profit] / Sales[Cost Amount]

Observe the error message that appears:

A single value for column 'Profit' in table 'Sales' cannot be determined. This can happen when a measure formula
refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to
get a single result.

A measure doesn’t apply line-by-line to a table so it doesn’t know what to do if a column is directly mentioned. At
the point of creation it is considering every row of data in every table so it is necessary to indicate what type of
operation to perform over all of these rows.

35. Change the formula to the following and press <ENTER>:

Profit % = SUM(Sales[Profit]) / SUM(Sales[Cost Amount])

Note the use of the SUM formula to specify that the values in all of the relevant rows should be summed.

The measure has been created under the “Sales” table and is denoted by a small calculator icon.

36. Format the measure as a Percentage with 1 decimal place.

Power BI Training Day 1: Essentials


Lab Manual
37. Select the SalesAmount by SalesPerson bar chart and apply the same conditional formatting for the data
colors using the [Profit %] measure.

Observe that the chart is now correctly highlighting certain sales people who make more or less profit compared to
the amount they are selling.

To build upon this and give a taste for some of the power of DAX let’s create a simple year-to-date measure
calculation.

38. Create a new measure with the following formula:

Profit $ YTD = TOTALYTD(SUM(Sales[Profit]), 'Date'[Date])

39. Create a new matrix visual with the following fields:


 Rows: Date[Calendar Month Year]
 Columns: Product[ProductCategory]
 Values: [Profit $ YTD]

By building in additional business logic using calculated columns and utilising our date dimension in our data
model we’ve been able to easily use Power BI’s time intelligence functions.

40. Save your report which should be called “Sales and Delivery Report – Final [YOUR_NAME]”.
41. Close Power BI Desktop.

Power BI Training Day 1: Essentials


Lab Manual
Have additional questions,
or want to know more?

Contact
Lee Moran
Data & AI Practice Lead
Velrada Capital Pty Ltd
P. 1300 835 723
E. Lee.Moran@velrada.com

Perth
Level 18, 197 St Georges Terrace
Perth WA 6000

www.velrada.com
Power BI Training Day 1: Essentials
Lab Manual

You might also like