Professional Documents
Culture Documents
This chapter explains the structure and the different versions of Power BI, and we'll
create reports with visuals in Power BI Desktop.
1. Power BI
In the past, only specialized IT people could handle Business Intelligence. But the BI
tools have become more and more user-friendly, so that end users can also produce their
information needs themselves and share it with other employees or interested
parties. This is called Self-Service Business Intelligence . Power BI is such a tool that
makes this possible. There are three parts (layers) in Power BI: Power Query, Power
Pivot and Power View/Map, see figure 1.
Figure 1
In the first part, Power Query, the ETL process takes place. Data can be selected from
more than a hundred different sources via so-called connectors. You can think of various
databases, whether or not in the Cloud, but also files from the internet, Excel files, e-
mail, Facebook or Big Data via Hadoop. If a connector is not available within Power BI,
such a connector can often be downloaded via a third party. For example, there is no
connector for Exact software by default. This connector is easy to download, so that the
data from Exact software can also be loaded into Power BI. Data must be transformed
into a desired form. Once the data has been transformed, it can be loaded into the data
warehouse.
The second part, Power Pivot, can simply be seen as the data cube. That data cube has a
data model (design of the tables, including their relations) and the data itself in the
tables. Here we have fact and dimension tables. An important part of Power Pivot is
enriching the data with calculated measures, so that you can create a specific report. For
example, you have the data (facts/measurements) gross price and discount percentage.
But you want to show the amounts of the net price in the report. You can then add a new
(calculated) net price measure to the data.
The last part, Power View/Map, is to visualize the desired information need in graphs,
tables, geographical views or KPI meters.
The Power BI service can also be accessed directly at app.powerbi.com . In that Cloud
version of Power BI you can also load data and create reports, but this version is more
limited than the Desktop version. The reports that are published can be viewed or shared
in the Cloud version. There are also Power BI Pro and Power BI Premium (for large
companies). Only in the Pro or Premium version you can directly create dashboards and
share the reports. On a dashboard , parts (visuals) of different reports can be placed on
one new report. Dashboards can also be created from the reports that have been
published via Power BI Service.
Figure 2
2. Visuals
Example 2.1
A jeweler has made some data available via a Comma Separated Values (CSV) file. A
CSV file is a text file with which tabular data can be exchanged between different
information systems. The data is separated by a specific character, usually a comma, but
a semicolon (;) is also commonly used.
Four visuals are created for the report.
Visual 2.1.1:
1. Launch Power BI Desktop. From the ribbon Home > group Data > Get data, Text /
CSV. Click on Connect, see figure 3. If visible, you can select Text/csv
immediately after Fetch data.
The window Get Data are all sources that can be connect via an integrated
connector. Through that connection, data from the source is loaded into the Power BI
data warehouse.
Figure 3
2.Select the file Jeweler.csv and click Open. A preview of the data being loaded is
shown. At the top you can see that the separator is semicolon (;). The table has four
columns, ArticleNumber, Category, Gender, and Description. This step is the Extract of
the ETL process.
4. We enter the Power Query section of Power BI, see Figure 4. This step is the
Transform of the ETL process.
5.In this window you can, for example, delete columns or certain rows. In this example,
we want to keep all data, so there is no need to transform the data (ETL process). We do
change the name of the table Jeweler in Article. This can be done on the right-hand side,
under Properties.
Figure 4
6. Important to know is that columns have a data type. There are several numeric data
types, such as Integer or Decimal number. There is also a Text data type and a Date data
type , with or without the time format. There is also a True/False data type, also known
as Yes/No, On/Off or Boolean . In this, the well-known check marks are stored in
information systems (Passed, In possession of a driver's license, Insured,
Completed). There are other data types, but they depend on the database type. All data in
the column must be of the same type. The data type can be viewed or changed by
selecting the entire column (click on the column header). In the ribbon Transform >
group Any Column > Data Type, the Data Type is visible. The data type of
the ArticleNumber field is Integer, that of the other three columns is Text.
The icon next to the column name also indicates the data type. If you click on the icon
you can also change the data type.
7. Click in the ribbon Start > group Close > Close & Apply. The data is loaded into the
Power BI data warehouse. This step is the Load of the ETL process.
8.We come to the main Power BI window, see Figure 5. It has three panes on the
left: Report, Data, and Model.
9.Select the Data pane . The table with the data is displayed. If there are several tables,
the desired table can be selected on the right.
Figure 5
12. Click the visual Ring Diagram (Donut chart); it will appear on the canvas. We want
to see the number of articles per category in this diagram. Drag
the Category and ArticleNumber fields into the visual and make the visual slightly larger
to make it easier to read, see Figure 6.
Figure 6
14. It is grouped per category, of each category only one value is shown. Select the
layout of the visual under Format (the paint roller). Select the group Detail labels and
see at Label style different options. Finally select the last option All detail labels. All
important data is now shown with the labels. Turn the Legend on to Off. The legend is
not needed now; After all, the labels of the donut chart contain the categories.
15.The numbers at the labels are shown in trillions, for example the Earrings category ,
2bn (19%). The value 2bn stands for 2 trillion, which is a bit much.
19.In Format > Data colors you can manually select a different color for each
category. However, we leave it at the chosen colors.
20.In Format > Title change the title to Number of articles per category and center the
title at Alignment . Make the title slightly larger by increasing the Font size
to 16pt.
Visual 1.2:
2. Switch Format > Data label to On. The result of the count is immediately visible at the
end of the bars. In that group all kinds of settings can be made, such as the Label
position of the data label.
4.Make sure that the categories are shown in 12pt (located under Y-axis ), and that the
title is shown in 12pt , centered and changed to Number of articles per category. Also
show the labels in 12pt , see figure 8.
Figure 8
Visual 1.3:
1. We immediately create a third visual in the same canvas. Click anywhere in the blank
area of the canvas so that no visuals are selected, and place a Table visual below the
donut chart.
2.Place all fields from table Article into the visual Table. All fields are now in
the Fields pane under Values . There you can change the order of the fields in the table
by dragging.
4.Give the values in the table visual a font size of 12pt, via group Grid, see figure 9.
Figure 9
5.The sum of numeric fields is shown by default on the last line of the table visual. For
article number that is complete nonsense. Turn Off Format > group Total > Totals.
6.Note that Table is also grouped in the visual . Nevertheless, all values are now
shown. This is because the ArticleNumber field is in the table. ArticleNumber is the key
(PK) of the table, so all values are different, so no grouping. But if
you remove the ArticleNumber and Description fields from the table visual, for example,
the grouping is immediately visible in the table visual. Remove goes through Fields >
Values
Visual 1.4:
1. We make one last visual, a Matrix. That's one of the most important visuals. In Excel
it is called the pivot table. The name of the second step within Power BI, Power Pivot, is
derived from this. Many analyzes are made using matrices (pivot tables). If necessary, a
matrix provides very compact analytical information from billions of rows of data. In a
table we have only rows, but in a matrix we have rows and columns. Place
the visual Matrix in the canvas (click on an empty spot in the canvas first) next to the
table visual.
3.Now we are going to add a second dimension and that immediately shows the power
of a matrix. Drag the Gender field to Columns . We now assume that you know
that Columns are in the Fields panel . The numbers are immediately shown per category,
per gender (two dimensions), including the totals, see figure 10. If the totals (or
subtotals) are not desired, they can be disabled in the settings Grand
Total and Subtotals of the visual.
Note that different filters are active for each value in the matrix. For example, for the
first value, 829, the underlying dataset has a filter active on Ladies and Bracelets. The
number of ArticleNumbers for that filter is counted. But that applies to all values in the
matrix, including the totals. A total of 75 (5 × 15) different filters are active in the
matrix. Within BI, the term filter context is used for this. The value in a cell (calculated
measure) depends on the filter context. Of course, this does not only apply to the
visual Matrix, but to all visuals.
Figure 10
4.Choose Format > group Style > Bold header, and make sure that the values in the array
of visual font size 12pt shown through group Grid (Grid).
5. We immediately made a nice report of our data by visualizing it in four visuals, see
figure 11. The page with the visuals is full. If you want to create more visuals, a new
page can of course be created and the different pages can be given an appropriate name.
Figure 11
7. Exit Power BI and name it Jeweler. The file will have the extension .pbix (Power BI
Xml).
In this section we will practice with several tables between which a relationship has to be
established. We also practice with visuals with maps.
Example 2
Visual 2.1:
1.Open a new Power BI environment. From the ribbon Home > group Data > get Data >
Excel. Click Connect. Excel can also be selected directly, as the file format is often used
when exchanging data between information systems.
2.Select the Excel file Paprika export.xlsx. This Excel file has two
tabs, Country and Paprika. If you select it, a preview of the data will be shown. Place a
checkmark in both tabs and choose Load. Data does not need to be adjusted.
3.Select the Model pane . You see the two tables, but there is no relationship between the
tables yet. The relationship is based on country codes, key in table Country and foreign
key in table Paprika. In table Paprika the country codes are in column Code country and
in table Country in column Country code. If the field names are identical (eg Country
code), Power BI automatically establishes the relationship between the two tables. But if
you load data from multiple sources, 'relationship columns' can have completely
different field names. For example, customer number and relation number or employee
number and personnel number. If prompted to upgrade to a new model view, accept.
4. Select the ribbon Home > group Relationships group > Manage relationships. The
window Manage Relationships opens. Click on New. Select Country at the top of the
table and Paprika at the bottom of the table (automatically with two tables), see figure
12. Select the columns to be linked (Country code in table Country and Code country in
table Paprika ‒ the columns are shown in grayscale), see figure 12. Click OK. The
relationship management window is displayed again. Close this window.
Figure 12
Figure 13
6.In the Data pane, view the data of both tables. Note that the Country table
contains more countries than the Paprika table . So not all countries from
table Country are exported.
9.Drag the Color field from Paprika table to Columns .
10.Make sure that the column headings, row headings and values are shown in font
size 12pt: Format > Grid.
Visual 2.2:
1.Place a visual Filled map to the right of the matrix . In a filled map you can show the
data geographically, such as countries/regions, states/provinces or postal codes on a
digital map. Internet is used.
Figure 14
4.Turn off the legend and title in the layout of the visual, they are of no use.
Visual 2.3:
Figure 15
3. Turn off the title and make the Bubbles larger, set in the value 10.
4.The color of the 'bubble' can also be adjusted by Data Colors. Optionally, you can give
each country a different color in the group Data Colors > Show all > Off.
5. Now select Germany in the matrix. The country map now also zooms in on the town
in Germany where the 'bell' is placed. That is completely useless. We're going to adjust
that. Choose Format > Map controls >.Auto Zoom > Off. Select Germany again in the
matrix and view the result. Show all countries again.
Before you start creating a report, you should have thought about what that report should
look like and what kind of data you need to do that. The data in the data warehouse must
be enriched with additional data to be able to show certain overviews or graphs. This can
be done with calculated columns or with calculated measurements. A calculated
measurement is called a measure in Power BI . A calculated column calculates a new
value in an added column for each row in the table. The calculated value is immediately
displayed and stored in the new column. Measurements are widely used within BI. It is a
passive calculation that returns a value. This means that the measurement starts
calculating if there is (filter) context; if you use the measurement in a visual. This
provides a performance improvement and does not cost any physical memory space. A
measure is therefore NOT calculated row by row, as with a calculated column. A
measure is only calculated in a visual and works on the active filters (filter context). This
will be made clear with examples.
Example 3
We are going to enrich the report in Power BI from the previous section with three
additional visuals with calculated columns.
Visual 3.1:
4. By default, the program chooses the name Column for the column name. Delete that
text and replace it with the calculation you want:
5.If you enter the [ sign, all fields from the current Paprika table will be displayed, so the
field can be entered quickly by selecting it and then using the Enter or Tab key. Since
the Population field is in another table (Country), the RELATED() function must be
used. All related fields are also shown after the RELATED() function . The new column
is also shown in the fields of the table. The new field has a column icon so you can see
that it is a calculated column.
Remark:
• The tables in Power BI coupled through BI-term expanded tables. For the two tables in
the data model, the Paprika table is extended with the rows of the Country table . This
expansion takes place from the many-side to the one-side of the relationship between the
tables.
It can be seen as one table, but they remain separate tables. If you want to apply one
metric from the same row from another table, you need to use
the RELATED() function . In the example, the formula: Tons per 1000 people =
[Number of tons.] / ( RELATED(Country[Population] ) /1000 ) has
been applied. Table Paprika is the active table, so [Number of tons.] can be used directly,
but the corresponding entry [Population] from the same row comes from a related table
and for that you have to use RELATED(Country[Population]) .
•The formula language of Power BI is different from the formula language you may
know from Excel. In Power BI, the formula language is called DAX (Data Analysis
eXpressions). The basic functions from Excel also exist in DAX, but there are also many
other functions, such as RELATED(). DAX functions can work on the entire table and
therefore do not always return just one value, as in Excel.
6.Select the newly created calculated column in the field list and in the
ribbon , choose Column Tools > Formatting group > two decimal places. Tip: Check
after making a calculated column in this way, always the correct data type: Data type
> Format and the number of decimal places of the new column.
7.We create another new column to determine the number of tons of paprika's per 10
km2 of land area:
8.Make sure the new calculated column is shown with two decimal places.
9.Select the Report panel and create a Table visual below the matrix visual . Place
the Country field and the two new columns here. The long field names make the
columns showing wide, but they can be made narrower.
10.We want to sort the table by Tons per 1000 inhabitants. When you click on a visual,
three small icons appear (top right or bottom left of the visual). An icon with filter
information, a Focus mode icon to magnify the visual and a three-dot icon for More
options.
Figure 16
12.Remove the totals in the table via the panel Format of the visual.
Visual 3.2:
3.The colors ask to be adjusted (green, yellow, red). Match the colors. Brighter or deeper
colors can be shown via Custom color . Optionally, even a specific hexadecimal code
can be entered.
4.The legend can be turned off and the title of the visual can be centered.
5.Select the stacked column chart, and then click Clustered column chart or Clustered
bar chart. View the result. Turn the visual back into a Stacked Column Chart.
Visual 3.3:
2.Make sure that the columns are shown in the colors red, green and yellow. Tip: Select
the previously created stacked column chart and choose in the ribbon Home > group
Clipboard > Format Painter. Then click in the new chart.
Example 4
Jeweler LeMair has stores in the Netherlands, Belgium and Germany. In addition, there
is an internet site where orders can be placed. In addition to the three countries
mentioned, France is also served via the website. Customers can make a purchase
anonymously in the stores or use a loyalty card.
Visual 4.1:
1.Open the Power BI file LeMair.pbix (double click on file). The data has already been
adjusted and loaded, you will immediately enter the Power BI environment.
2.View the contents of the four tables in the Data pane . See the number of rows of the
tables. The Sales table has nearly three million rows!
3.View the relationship diagram in the Model pane , see figure 17. This clearly shows
the star schema, with the Sales fact table (only has many-to-one relationships) and
the Branch, Customer and Item dimension tables . The relationships between the tables
have already been established. Select a relation; the linked fields are displayed.
Figure 17
Remark:
•The calculation of a measure should always contain a DAX function that aggregates
(summarizes)! Common DAX functions for a measure
are: SUM(), AVERAGE(), MIN(), MAX(), COUNT(), COUNTROWS(), and DISTINC
TCOUNT(). The last function counts the number of unique values in a column.
•No new column is created after entering the formula. Nothing changes in the table. A
measurement is not calculated in a row of a table, which is why a measurement is NOT
shown as a column in the table. The measurement is only calculated in a visual based on
active filters.
•For measurements, the full field name must always be entered, so Sales[Amount] and
not just [Amount].
• By selecting the measurement, the format can be adapted: Measure tools > group
Formatting, for example, display in Euro.
5. Select the panel report and place the visual Card With such a visual you can, for
example, show a prefix. Place the measurement Offset in the map (5M). Make sure the
exact outcome (4,732,828) is shown through pane layout (size) of the visual in the
group Data label > Display units > None).
Visual 4.2:
2.We only see store numbers in the matrix, not the store name. If you want to see store
number and store name, a calculated column must be added. Select the Data pane and
select Store table .
3.Create a new calculated column in the Stores table: Store = Stores[StoreNumber] & " –
" & Stores[StoreName]
4.We are going to use the new calculated column in the matrix visual. Select the maxtrix
visual, remove StoreNumber from Rows and place the calculated
column Store in Rows. Now the full name (store number and name) is shown in the
matrix. Note: Internet sales are booked at store number 999.
Visual 2.4.3:
2.Select the Sales Price column and use Column tools > Formatting group, to set the
number of decimal places after the decimal point to 2 ().
3.Since we want to determine the revenue on different filters, for example per store, per
country or per year, a measure is necessary for the revenue. The line-level revenue
is [Amount] * [UnitPrice]. But a measure must always have an aggregated (summarized)
function, so that it can be determined over the active filters (filter context). So you would
expect SUM( [Amount] * [UnitPrice] ). However, within the DAX function SUM()
there can only be one column, SUM(<Column>), and no calculation (expression). DAX
has another function for this: SUMX(<table>,<expression>). That function has two
arguments. The first is a table and the second is the expression (calculation). Select
table Sales and create the measurement:
The first argument indicates that the calculation is made in the Sales table , and then the
calculation (expression) follows in the second argument. The Revenue measure has been
added to the fields of the Sales table .
4.Select the Report panel . Create the new visual in a new tab. Click the + sign next to
the Page 1 tab .
5.Insert visual Stacked column chart in the new canvas. Drag the field Country
code from the table Customer to the option Axis of the column diagram, and the
measure Revenue to Values. The data labels in the visual are turned on.
Visual 4.4:
2.A date field (Order Date) has a hierarchy (year, quarter, month and day) by
default. This can be seen in the Columns option of the matrix. If a field with a hierarchy
is applied in a visual, additional buttons become available. Those extra buttons can be
above or below the visual. The highest hierarchy, Years, is shown by default.
3.The next level in the hierarchy, Quarters, is selectable via a button with the twin
arrows. Show the next level of the order date (Quarters). Note that, for example, all years
for quarter 1 are together. This probably makes little sense, but it can be solved.
4.Show the turnover per year again via the button with the single up arrow. Then click
on the button with the symbol where the arrows split. Now the quarters per year are
shown. Clicking the same button again expands one level down; per year per quarter the
months become visible. The overview scrolls to the year 2022. Note that many measures
(Turnover) have been performed in this overview. A measure works on the filter and
always produces one value per filter. For example, filter Country Code = 'BE' and Order
Date in January 2022 yields one value, €664,697.04. As soon as a measure is applied in
a visual, the underlying table is cycled through. Iterating through the table is called an
iteration .
5.Make sure that the year, quarter and month are visible in the matrix visual. Finally, we
are going to add slicers. A slicer is an alternative way to filter. Place a
visual Slicer below the column chart.
8.Place a new slicer to the right of the slicer you just created.
9.In the field list, the OrderDate field in the Sales table has an expansion symbol, a V
sign, in front of the field name. Click on this; this makes the Date Hierarchy visible. The
date hierarchy can also be expanded. This shows the hierarchy of a date field
11.In a slicer with a numeric value, two fields are shown by default, with a lowest and a
highest value. The intermediate value, including boundaries, is filtered on. But the slicer
type can be changed. At the top right of the slicer you can select a slicer type at the V
sign. Default type is Between for numeric values. Research the different slicer
types. Now select the slicertype List and make sure the option Select All appears.
12.Place two more slicers, with which you can filter by quarter and month.
13.We can further perfect the slicers. Select only the year 2022 in the year slicer. In the
slicer with quarters, you can now choose from four quarters. But the revenue data runs in
2022 through August, so there's no fourth quarter. We can make sure the fourth quarter
doesn't become available.
14.Select the quarter slicer. Then drag from the field list of measure Revenue to the
panel filters, filters to this visual, data fields add,
15.Choose for the condition within that filter: is not blank, and click on Apply filter. The
fourth quarter disappears from the slicer, because in the fourth quarter there is empty for
the year 2022.
16. The same goes for the slicer with the months. For the year 2022, only the months of
January to August have revenue. Make sure that the month slicer only shows the options
that have revenue, see steps 14 and 15. The Filters panel can then be collapsed again.
Visual 4.5:
1.The last visual creates a line chart . Select the Report panel and create a new report.
2. Place the new visual tab Line chart and make the field of visual larger so it is easier to
read. From the date hierarchy of the Order date, just drag the Month field to the Axis
and Revenue to Values of the visual.
3.Add a slicer visual in the report and drag the Year and Quarter fields from the date
hierarchy into the slicer. Year above Quarter and slicer type List. Make the size of the
slicer appropriate.
You can place multiple fields from the same table in a slicer to create a hierarchy within
the slicer.
4.Turn pane size of the slicer in group controls Selection by selecting the All
option to On (Show "Select All" option, On).
5.In the same panel, the display of the hierarchy can be modified within the Group Items
option Expand / collapse icon. Choose the icon for Plus/Minus as the display.
7.In the slicers, select year 2021 (all quarters) and only ladies bracelets.
8.Select the line chart visual and change some properties in the Format pane :
-Change under Data colors the color of the turnover in bright red (selectable via Custom
color ).
9.Right to the rolling brush is a third switch Analytics. Select that button. With a line
chart, all kinds of analytical lines can be displayed in the visual.