Powerbi
Powerbi
Powerbi
Introduction to Power BI
6
CHAPTER 1. INTRODUCTION TO POWER BI
Service or the Mobile app to have a glance at how the business is performing.
But on the other hand, if you are a developer, you would be using Power BI
Desktop extensively to publish Power BI desktop reports to the Power BI
Service.
In the upcoming modules we would be discussing about these three components
- Desktop, Service and Mobile apps - in more detail.
Depending on the user role, the user might spend most of the time in one of the
three components than the other.
7
CHAPTER 1. INTRODUCTION TO POWER BI
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.
8
CHAPTER 1. INTRODUCTION TO POWER BI
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.
9
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.
10
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.
11
CHAPTER 1. INTRODUCTION TO POWER BI
12
Chapter 2
Power BI can connect to a whole range of data sources from Excel sheets and
local databases to several Cloud services. Currently, over 60 different cloud
services have specific connectors to help you connect with generic sources through
XML, CSV, text, and ODBC. Let us start connecting to one of the data sources.
For today we will be working on the gap_minder_map.csv file.
13
CHAPTER 2. IMPORTING DATASET AND MODELLING
Once we select this, we go ahead and select the CSV option under the file
subheading.
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.
14
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.
15
CHAPTER 2. IMPORTING DATASET AND MODELLING
You can replace a current step in the query with Replace current step or add
a new step to the query with Add new step.
• Click Add new step.
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.
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.
16
CHAPTER 2. IMPORTING DATASET AND MODELLING
this is not a key capability of Power BI. Furthermore these changes do not affect
the source data set. These changes are actions that Power BI takes whenever
you load in that dataset.
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.
• 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.
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.
18
CHAPTER 2. IMPORTING DATASET AND MODELLING
19
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.
20
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.
21
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
22
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.
23
CHAPTER 3. PLOTTING
Legend: By region
Find the Average life expectancy of each region by year.
Challenge 1: Solution
This shows the average of life expectancy in all countries in a given region,
and plots it.
24
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
25
CHAPTER 3. PLOTTING
Power BI computes average of Life expectancy for countries in each region and
shows four average lines corresponding to four regions.
26
CHAPTER 3. PLOTTING
Challenge 2: Solution
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.
27
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.
28
CHAPTER 3. PLOTTING
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.
Challenge 3: Solution
• gdp_percap as x.
• life_exp as y.
• region as the legend.
29
CHAPTER 3. PLOTTING
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.
30
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.
31
CHAPTER 3. PLOTTING
Challenge 4: Solution
32
CHAPTER 3. PLOTTING
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 recognises the names of countries however make sure
they are spelt correctly or use with longtitude and latitude values to ensure
accuracy.
33
CHAPTER 3. PLOTTING
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.
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.
34
CHAPTER 3. PLOTTING
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.
Challenge 5: Filtering
A. On the previous plot, create a filter for region.
B. Visualize gdp_percapita vs life expectancy for: Americas
35
CHAPTER 3. PLOTTING
Challenge 5: Solution
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.
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.
36
CHAPTER 3. PLOTTING
Challenge 6: Slicer
Focussing on the Americas region, create a slicer for countries and examine the
differences between Argentina and Bolivia.
Challenge 6: Solution
37
CHAPTER 3. PLOTTING
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.
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.
38
Chapter 4
Now that we have visualised the data and created various types of plots we need
to save our visuals.
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.
39
CHAPTER 4. SAVING AND EXPORTING
It takes about 2-3 mins to finalise the report and you will see the following
success message on your screen.
40
CHAPTER 4. SAVING AND EXPORTING
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.
41
CHAPTER 4. SAVING AND EXPORTING
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:
42
CHAPTER 4. SAVING AND EXPORTING
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.
43
CHAPTER 4. SAVING AND EXPORTING
44