Powerbi Intro
Powerbi Intro
Setup 2
1 Introduction to Power BI 6
1.1 Overview of Power BI ........................ 6
1.2 The parts of Power BI . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3 Use of Power BI and roles . . . . . . . . . . . . . . . . . . . . . . 6
1.4 Power BI flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.5 Use Power BI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.6 Building blocks of Power BI . . . . . . . . . . . . . . . . . . . . . 8
1.7 Power BI Services .......................... 10
1.8 Power BI licence . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3 Plotting 20
3.1 Visualization Panel . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.2 Plot modifications . . . . . . . . . . . . . . . . . . . . . . . . . . 28 3.3
Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.4 Explore Marketplace for other visualizations . . . . . . . . . . . . 30 3.5 Filters . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 3.6 Edit interactions . . . . . . . . . . . . . . . . . . . . .
. . . . . . 37
These are the course notes for the “Introduction to Power BI” course given by the
Monash Bioinformatics Platform1 for the Monash Data Fluency2 initiative. Our
teaching style is based on the style of The Carpentries3.
• PDF version for printing4
• ZIP of data files used in this workshop5
During this workshop we will be using Power BI Desktop installed on your computer.
There are several ways to download Power BI Desktop, depending on which system
you use.
1. Windows
• Windows Store
The first option is to visit Windows Store to get the Power BI Desktop app 6and install
it. Note that the system requirements is Windows 10 version 14393.0 or higher.
1
2
3
4
5
6
1
If you are using a Monash machine, try searching “Power BI” in “Software Center7”
and install it. For questions concerning installation on a Monash machine, you may
contact eSolutions8 for help.
• Power BI website
You can also download Power BI Desktop from the Power BI website 9 and install it as
an application on your computer.
7
8
9
2
CONTENTS
• Power BI service
Or if you prefer Power BI Service10, you can get it by clicking the “Download” button in
the upper right and selecting “Power BI Desktop”. To use Power BI service, you may
need to sign in11 your Microsoft account.
After the setup process, you will be able to see the following Start Screen.
2. MacOS
Power BI Desktop is not available on Macs. However, you can run a Windows session
on your Mac via BootCamp12 or using a similar application.
10
11
12
3
3. Linux
Currently it is not possible to install Power BI desktop on Linux. You can choose to
install it on a Windows Virtual Machine like VirtualBox 13 or using a similar
application.
After installing Power BI Desktop, you can sign up for Power BI using your Monash
account here1415. By signing in the Power BI Desktop, you will be able to save your
work and later publish it to the Power BI service.
Data
Download the data file gap-minder.csv16 for the course.
Source code
This book was created in R using the rmarkdown and bookdown packages.
• GitHub page17
13
14
15
16
17
18
19
4
Chapter 1
Introduction to Power BI
These three elements— Desktop, the Service, and Mobile apps - are the backbone
of the Power BI system and lets users create, share and consume the actionable
insights in the most effective way.
5
CHAPTER 1. INTRODUCTION TO POWER BI
Depending on the user role, the user might spend most of the time in one of the
three components than the other.
1.6 Building blocks of Power BI
The basic building blocks in Power BI are:
6
CHAPTER 1. INTRODUCTION TO POWER BI
• Visualizations
• Datasets
• Reports
• Dashboards
• Tiles
1.6.1 Visualizations
A visualization is a representation of data in a visual format. It could be a line chart, a
bar graph, a color coded map or any visual way to present the data.
1.6.2 Datasets
A dataset is a collection of data that Power BI uses to create its visualizations.
You can have a simple dataset that’s based on a single table from a Microsoft Excel
workbook, similar to what’s shown in the following image.
7
CHAPTER 1. INTRODUCTION TO POWER BI
Dataset can also be a combination of many different sources, which can be filtered
using Power BI and combined into one to use.
For example: One data source contains countries and locations in the form of
latitude and longitude. Another data source contains demographics of these
countries like population and GDP. Power BI can combine these two data sources
into one dataset which can be used for visualizations.
An important feature of Power BI is the ability to connect to various data sources
using its connectors. Whether the data you want is in Excel or a Microsoft SQL Server
database, in Azure or Oracle, or in a service like Facebook, Salesforce, or MailChimp,
Power BI has built-in data connectors that let you easily connect to that data, filter it
if necessary, and bring it into your dataset.
After you have a dataset, you can begin creating visualizations that show different
portions of it in different ways, and gain insights based on what you see. That is
where reports come in.
1.6.3 Reports
In Power BI, a Report is a collection of visualizations that appear together on one or
more pages. A report in Power BI is a collection of items that are related to each
other. We will be working with the gapminder data to create the report below that
looks at the GDP, population and life expectancy by global regions.
8
CHAPTER 1. INTRODUCTION TO POWER BI
Reports let us create and structure visualizations on pages based on the way the we
want to tell the story.
1.6.4 Dashboards
A Power BI dashboard is a collection of visuals from a single page that you can share
with others. Often it is a selected group of visuals that provide quick insight into the
data or story you are trying to present.
A dashboard must fit on a single page, often called a canvas (the canvas is the blank
backdrop in Power BI Desktop or the service, where you put visualizations). Think of
it like the canvas that an artist or painter uses — a workspace where you create,
combine, and rework interesting and compelling visuals. You can share dashboards
with other users or groups, who can then interact with your dashboards when
they’re in the Power BI service or on their mobile device.
9
CHAPTER 1. INTRODUCTION TO POWER BI
1. Ribbon - Displays common tasks that are associated with reports and
visualizations.
2. Report view, or canvas - Where visualizations are created and arranged. You
can switch between Report, Data, and Model views by selecting the icons in the
left column.
3. Pages tab - Located along the bottom of the page, this area is where you would
select or add a report page.
4. Visualizations pane - Where you can change visualizations, customize colors or
axes, apply filters, drag fields, and more.
5. Fields pane - Where query elements and filters can be dragged onto the Report
view or dragged to the Filters area of the Visualizations pane.
Working in Power BI desktop and creating visuals will be the focus of todays session.
20
10
CHAPTER 1. INTRODUCTION TO POWER BI
11
Chapter 2
Once we select this, we go ahead and select the CSV option under the file
subheading.
12
CHAPTER 2. IMPORTING DATASET AND MODELLING
Then browse the file and select the necessary CSV file. Press on Connect to have a
quick preview of the file. Once we click on Load, Power BI will successfully import the
file. Any errors will then pop up ready to be analysed and fixed.
13
CHAPTER 2. IMPORTING DATASET AND MODELLING
If there are any errors in the data load, select View errors to check any detected
errors. Alternatively, close the pop up and click Edit queries to check for any errors.
This will query and list the errors in the data.
The life_exp column is displaying as text data. This is a problem as we may want to do
numerical calculations with this data. We should change this to a numerical data
type.
14
CHAPTER 2. IMPORTING DATASET AND MODELLING
Once necessary changes are made, it is important to refresh and check if the change
was applied. We can do this by clicking on the Refresh Preview button on the ribbon.
You will notice that this has created errors due to several cells containing N/A.
You can view the data in the Data section on the left sidebar. By applying a filter to a
particular column, the null values can be analysed. To replace any null values, go to
the Query Editor and use the Replace values option in the Transform tab. You can
also remove error values by right-clicking a column and selecting the Remove errors
option.
Look in Errors in gap-minder in the Query Errors folder. You will notice that all the
years for 1820 have a whitespace in it that is causing an error.
This will replace all errors with the value 1820. In this case this works as only one
value is causing an issue. You can use Replace values to find and replace several
values.
15
CHAPTER 2. IMPORTING DATASET AND MODELLING
You may have noticed errors in the OECD column. If you tried to fix these with a
Replace values option you will find that this does not work. This is because Power BI
has automatically made this column a Boolean column and is intentionally ignore
this values as they produce errors. To get around this you would have to change the
column to a text column, find and replace the values, and then change the column
back to boolean. This are additional steps that Power BI will be made to run
everytime you load this data and is inefficient.
Cleaning up the source data as much as possible in the early stages will save you
problems in the future, this is true for any data analysis. The best approach is to
clean up and eliminate errors from your data before you import into Power BI. This
will minimise the amount of actions that Power BI takes and speeds up the loading
process. This cleaning process may take several iterations as you work with Power BI
and the data and uncover more inaccuracies. Power BI does ignore blank and error
values when it comes to analysis and visualisation but this may not always be the
best approach.
Cancel the last two steps in the Applied steps by clicking on the red crossmark right
next to Removed Errors and Replaced Value.
16
CHAPTER 2. IMPORTING DATASET AND MODELLING
audience to understand your data. This will often save you trouble in the future
when it comes to working and presenting the data.
There are two ways to rename the columns in Power BI. Right-clicking on the header
of the column gives you a menu of functions that you can do to the column. Select
Rename to rename the column. You can also click on the column and then click on
the Transform tab, from here you are presented a variety of transformation functions
for the column. From here you can click on Rename.
• Right-click on the name column header, click on Rename and rename the
column to Country.
• Click on the header for life_exp. Click on the Transform tab and click rename.
Rename the column to Life expectancy.
2.3.2 Adding and removing columns
2.3.2.1 Removing columns
Often when dealing with raw data you will find columns that are meaningless or
unsuitable for your analysis. You can remove these columns in Query to eliminate
clutter and streamline the data set making it easier to work with.
There are two ways to remove columns in Power BI. As in renaming a column, you
can right-click the header, which will present a menu with the option to Remove. You
can also click on the column, click on the Home tab and then click Remove Columns.
17
CHAPTER 2. IMPORTING DATASET AND MODELLING
Challenge 2: Add
Perform a simple mathematical operation and add this as a new column. Let’s say
you want to calculate Total Gross Domestic Products (GDP) per country. As Total GDP
= Population x GDP per capita, using the new gdp_percap column you created in the
previous example, use Custom Column to create a new column with Total GDP per
country.
Once all the required changes are done, select Close & Apply going back to the main
Power BI Desktop interface.
18
Chapter 3
Plotting
In the previous chapter, we saw how to import data into Power BI. We also did some
basic pre-processing of data like cleaning the data, changing the type of data, and
dealing with null and error values. In this section, we are going to work with our
already processed data.
19
CHAPTER 3. PLOTTING
We want to see how life expectancy life_exp varies with time year in years. After
dragging the columns to their respective fields, we get our first scatter plot.
This plot does not seem entirely correct.
• Click the drop down on both life_exp and year fields. These fields are being
automatically summed.
• Click don’t summarize.
PowerBI automatically summarizes numerical data. Be aware and check this when
you add new numerical data to visualization fields.
An overall increasing trend can now be seen after year 1900.
20
CHAPTER 3. PLOTTING
The final interface will look like the image below. The plot will be at the left of the
Visualization panel.
In general, this will be the procedure to create any type of plot in Power BI i.e. select
the chart type from the Visualization panel and then drag data to the relevant fields.
The above scatter plot is not informative. Let’s explore what else we can do with this
plot.
X-Axis: year
Y-Axis: life_exp
Legend: country
21
CHAPTER 3. PLOTTING
We have colored each dot by the country. This plot shows the trend of life
expectancy for each country with years. Since there are so many countries in our data,
this plot looks messy, unclear and our plot legend “explodes”.
Let’s make this better.
Use the following parameters to create your chart:
X-Axis: year
Y-Axis: life_exp Legend:
region
This plot colors each data point by the region where the country is located. The
summarize option summarizes the life expectancy life_exp for each region.
• Size: By population
• Report what follows.
Challenge 1 Scatter plot
Create a chart with the following options:
22
CHAPTER 3. PLOTTING
X-Axis: year
Legend: By region
Challenge 1: Solution
This shows the average of life expectancy in all countries in a given region, and plots it.
23
CHAPTER 3. PLOTTING
This bar plot shows GDP per capita variation over time (in years) for all 4 regions.
We get differently colored lines for each country. Now try changing the Legend to by
region.
Axis: Year
Values: Average of Life_exp. Select Average Legend: By region
Power BI computes average of Life expectancy for countries in each region and
shows four average lines corresponding to four regions.
24
CHAPTER 3. PLOTTING
As you may have noticed, dragging and dropping Fields into the Fields tab will
automatically change the data visualization. You can easily swap or add new fields
using the drag and drop to change and discover new ways to visualize your data. You
can remove fields by clicking the x next to the name.
25
CHAPTER 3. PLOTTING
Here you can add reference lines for various measures. Add a trend line to your
chart.
These options will vary depending on the chart that you use.
26
CHAPTER 3. PLOTTING
• Click on Title and change it to a clearer name like ‘Regional average life
expectancy since 1800’.
You can also edit the legend or axis labels. Let’s make the axis labels more clear.
• Change the font for the x and y axis to Segoe(Bold), increase the font size to 12
and color to black.
The options available will be different for each visualization. Using these options will
greatly increase the engagement and understanding of your visuals. Let’s go and
change the names of all the other visuals to something more meaningful.
27
CHAPTER 3. PLOTTING
Challenge 3: Solution
• gdp_percap as x.
• life_exp as y.
• region as the legend.
As you can see, this visualization is messy and confusing. We will show ways to make
this visualization clearer later on.
3.3 Pages
At this stage you will have a lot of visuals but not much room. Power BI has a
capability to create multiple pages in a report. When it comes to publishing your
report, you can choose to show or hide different pages according to need or use
individual visuals for dashboards. Let’s start a new page and move the most recent
visual you have created on to that page. You can do that by clicking on the visual and
then clicking cut on the Home tab of Power BI. Move to the new page and click
paste. You can also use CTRL or Command + X and then CTRL or Command + V in the
same way as cutting and pasting text in a text editor.
28
CHAPTER 3. PLOTTING
This will pop a new window, where you can search for various types of templates.
We are looking for the Word Cloud template. Type Word Cloud in the search box,
once you find the template click on the Add icon. This will add it to the Visualization
panel.
29
CHAPTER 3. PLOTTING
• Category: name
• Values: GDP per capita
Challenge 4: Solution
This plot tells us if a country was an OECD member by the color of the bubbles.
These categories can be seen in the legend at the top of the chart. It also indicates
the population size of each country by the size of bubble. You can also use the
country field alongside or replacing the longtitude and latitude values. Power BI
30
CHAPTER 3. PLOTTING
recognises the names of countries however make sure they are spelt correctly or use
with longtitude and latitude values to ensure accuracy.
Select Quick Measure on the Home tab. This will give you a variety of different
calculations you can use to create measures that can be used in your visualisations.
Let’s say you want to find the max average life expectency. Select “Max per
category”, add life expectency to the base value and add country to the category. You
will see a new field appear in your Fields pane. You will also see a small calculator
icon next to the name which indicates this is a measure. Now lets see what this
calculates. Create a Matrix visual. This visual is a tabular visual which we can use to
show and examine values. Add the new field the Matrix. A number should now show
up that should be the max average life expectency for a country in the data. We can
break this down by adding region to the rows to see the max values depending on
region. We can then add country below region to give a hierachy that shows the max
values for each function.
Let’s look a bit more at the measure you just created. Click on the field and at the top
of the visual, an equation box with an equation should appear. This is the calculation
that Power BI is doing based on what you set up in the quick measures prompt. This
formula is using the DAX formula language. This is similar to Excel formulas and there
are some overlaps so if you are familiar with Excel you will be familiar with a few of
the DAX functions. You can edit and formula in your quick measure or write one from
scratch using the New Measure option on the Home tab. DAX will not be covered in
this workshop however you can find the DAX reference guide on the Microsoft Power
BI website. One thing you may notice is that calculating the average for a long period
of time, especially when there has been inconsistent data collection like the life
expectency values, might not be meaningful or useful for users looking at your
visuals. This is where being able to filter and slice your data is important.
3.5 Filters
Now that we have a set of visuals showing different information, we come to the
most important part of data visualisation which is communicating and telling the
story of the data. Right now these visualisations, while interesting and potentially
useful after some close examination, are difficult to comprehend to the average
person or if used in a quick presentation. This is where we will be examining filters.
31
CHAPTER 3. PLOTTING
Filters are a powerful way to break down and show specific parts of the data. You can
access the Filters panel through clicking Filters.
You can filter data for individual visualizations, pages and for the entire report. Let’s
have a look at page 2 of our report. This page is rather confusing, we have lots of
points on the map for most countries in the world and we have calculations looking
at average GDP and life expectancy for 200 years. This is a lot of different information
that has been calculated over a diverse timeline.
Select the scatter plot you created for challenge 3. Click on the Filter panel which is
adjacent to the Visualization panel. Drag the year field and place it in Filters on this
visual bar.
Change the filter type to Basic Filtering Now you have all the years as a scrolling list.
Select any one year and you can see the data for that particular year. For example, if
we want to look at this data from year 2010, select 2010 in the filter panel.
32
CHAPTER 3. PLOTTING
Challenge 5: Filtering
A. On the previous plot, create a filter for region.
This has improved and filtered the data for one visual but what about the rest? This
is where the different filter options are important. Filters on this visual filters the data
only for that visual, the rest of the visuals are unaffected. Filters on this page filters
the data for all visuals on the page. Filters on all pages filters for all pages on the
report. Be aware of this option as this will filter data values and options on any new
visual you create on any page.
As we would like this page to be focussed on the Americas region in 2010 let’s
change the above visual filter into a page filter. This will mean that this page will only
show data from that region and that year. This will also restrict the end user from
looking at other regions or years. What if we would like to give the user some power
in exploring the data? This is where slicers come in.
33
CHAPTER 3. PLOTTING
3.5.1 Slicer:
Slicers allow you to put in controls in which the user can explore the data options.
NOTE: Slicers are affected by Filters so a Slicer for region on the current page that has
a Filter to Americas only will only show the option of Americas.
Let’s go back to our first page and create a few Slicers.
In the chart types, locate Slicer. Create a new blank Slicer chart. Drag and drop the
region column in the data field. We have created a slicer and can visualize data for
each region separately. Since Power BI is highly interactive, this slicer is applied to all
the charts that we have created and will show the results for selection in the slicer.
You can chose to apply slicer to specific charts by turning it off for other charts. We
will cover this in the next section.
Note: Hold the CTRL button to select more than one option. You can also change the
appearance of the slicer the same was as a visual in Format tab. Select General and
change orientation to horizontal for clickable buttons instead of checkboxes.
Challenge 6: Slicer
Focussing on the Americas region, create a slicer for countries and examine the
differences between Argentina and Bolivia.
34
CHAPTER 3. PLOTTING
Challenge 6: Solution
Selecting None will mean that the related visual will not change depending on
interactions with the selected visual. Change one of the scatter plots to None and
select a different data point on the line chart to see the effect. Select Asia on the line
chart again. Currently the bar chart highlights the relevant section. Select the filter
icon to change and select another data point on the line chart to see the effect.
Note: existing elements on the page may interfere with the Edit interactions icons.
Resize and move your visuals to avoid this.
35
CHAPTER 3. PLOTTING
This also affects slicers, selecting the slicer will show the same Edit interactions icons.
You may not want the average life expectancy by region visual to change depending
on which countries are chosen. Select the country slicer and select None on the
visual to stop that visual changing due to the options on the slicer. Every visual
interacts with all other visuals individually. Check the Edit interactions to make sure
all your interactions work as expected.
36
Chapter 4
The file extension for Power BI files is “.pbix”. The .pbix files are highly compressed
file types that contains all the graphics along with the actual data.
Note: If you share your .pbix file with others, your actual data gets shared as well.
37
After clicking on Publish to Power BI, you will be prompted to select a destination on
the Power BI server where you want to publish your report. The default setting is My
It takes about 2-3 mins to finalise the report and you will see the following success
message on your screen.
38
Congratulations! The report has been published to your workspace on PowerBI. To
access it, click on Open <YOUR_FILENAME.pbix> in Power BI.
After you click on the link, you will be taken to Power BI’s login through Microsoft.
You need to fill in your login credentials.
39
Once you sign in, you will see the Power BI dashboard. Scroll through the tabs on the
top - Dashboards, Reports, Workbooks and Datasets. We are interested in the
Reports tab because that is where you can find your published report. The different
types of actions can be seen under the Actions tab. These actions include - share,
analyze in Excel, quick insights etc. Hover over the different symbols to find out what
they do and select the appropriate action.
We want to take a look at our report and share it with others. Let’s click on the
report itself. You will see a similar screen showing your report:
40
If you click on Edit on the top, you will be able to edit mode and perform nearly
everything you can in the Power BI desktop.
You can see all the Visualization options and fields in the Power BI server. Click on
the Share button in the top left corner. This allows you to share your report with
others.
41
42