Lab Manual 05
Lab Manual 05
LAB MANUAL 5
Date:
Name:
Reg#: Group:
Marks: Signature:
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
1. Overview of Power BI
Overview
Introduction to Power BI
3. Power BI Desktop
Power BI is a free application that can be downloaded and
installed on the system. It can be connected to multiple data
sources. Usually, an analysis work begins in Power BI
Desktop where report creation takes place. The report is then
published to Power BI service from where it can be shared to
the Power BI Mobile apps so that people can view the reports
even on mobiles.
Installation
4. Getting Started
Let us now get an idea about working with Power BI Desktop. In
this section, we shall explore it a bit to get accustomed to its
interface.
Power BI Workspace
Basic views
Web
You can also use the data from the web. Here is a dataset which
presents the best and the worst states for retirement in the U.S.
Simply select Web as an option in Get Data and enter the name of
the url.
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
5. Transforming Data
After the data has been loaded, it becomes visible under
the Fields Tab. From here, we can modify our datasets with the
help of Query Editor. Query editor can be used for modifying
datasets irrespective of their data source. We can do
manipulations like renaming a dataset, removing a single or
multiple columns, etc. in the query editor. The Query Editor can
be accessed by clicking the Edit Queries button on the Home Ribbon.
Using the same Financial data, that we used above, let’s shape
data to meet our needs. Let’s create a custom column called New
Manufacturing Price, which is equal to:
([manufacturing Price])*3
POWERED BY
Removing columns
6. Reports
Reports are a collection of visualizations that can be created on
one or more pages. These visualizations are usually related to one
another.
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
7. Dashboard
A dashboard is a collection of several views, enabling one to
compare a variety of data simultaneously. Whereas the report can
encompass various pages, a Dashboard is a single page interface.
Creating a dashboard
Once we have the dataset ready with all the manipulations done,
we can proceed for the Dashboard creation process. A Power BI
dashboard, also known as canvas, consists of many visualizations
on a single page which helps to tell a story. These visualizations
called tiles are pinned to the dashboard from the reports.
Let’s now try to understand what insights we can get using
superstore data set:-
Sales by Country
Sales by Product
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
Power BI & R
Pre-requisites
Make sure you have the following installed and running on your
local systems:
R
A separate R integrated development environment (IDE) like
R Studio.
It is also important to note that:
Only data frames are imported
Any R script that runs for more than 30 min gets
automatically timed out.
Verify that R and R studio are installed on your system. Launch
the Power BI and go to Options and Settings -> Options
POWERED BY
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
install.packages("dplyr")
install.packages("data.table")
install.packages("ggplot2")
POWERED BY
Now, use the following R script to import the Iris data. We will get
a new dataset called iris_mean which contains the mean for each
of the four measures, grouped according to the values in
the Species column (Source: Power BI Introduction).
library(dplyr)
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
POWERED BY
geom_point(aes(color=Species), size=2) +
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
theme_bw() +
theme(title=element_text(size=15, color="blue3"))
POWERED BY
needed to do the same. But before that there are few pre-
requisites:
Make sure that Python is up and running on your local
systems.
All required packages and libraries should also be loaded
such as pandas, matplotlib, etc.
Currently, only pandas dataframe are supported.
Any Python script that runs for more than 30 min gets
automatically timed out.
Python needs to be enabled before we can use it. Launch the
Power BI and go to Options and Settings -> Options
Restart Power BI and you get the Python icon both in visualization
as well as in the Transform tab.
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
Steps:
To run your Python Script, select Get Data > More>Other > Python
script as shown below.
Now, simply paste your Python script here in the window that
opens. Select OK to run the script which and then imports the
resulting datasets into the Power BI Desktop workspace.
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
dataset.plot()
plt.title("Sales Vs Profit")
plt.show()
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
POWERED BY
plt.matshow(dataset.corr('pearson'))
plt.show()
POWERED BY
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
sns.set(style="darkgrid")
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
plt.show()
POWERED BY
Python Dashboard
Publishing