0% found this document useful (0 votes)
250 views

Data Visualization With Power BI

asdfsdaf

Uploaded by

santo nino
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
250 views

Data Visualization With Power BI

asdfsdaf

Uploaded by

santo nino
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 49

https://www.datacamp.

com/tutorial/data-
visualisation-powerbi
Data Visualization with Power BI
Learn how to analyze and display data using Power BI and make better, more data-driven
decisions.
Apr 2019 · 16 min read
Contents

 1. Overview of Power BI

 2. Advantages of using Power BI

 3. Power BI Desktop

 4. Getting Started

 5. Transforming Data

 6. Reports

 7. Dashboard

 8. Power BI’s integration with R & Python

 9. Saving and Publishing

 10. Conclusion

Share

Our goal as Data Analysts is to arrange the insights of our data in such a way that everybody
who sees them is able to understand their implications and acts on them accordingly.

Power BI is a cloud-based business analytics service from Microsoft that enables anyone to
visualize and analyze data, with better speed and efficiency. It is a powerful as well as a flexible
BI tool for connecting with and analyzing a wide variety of data. Many businesses even consider
it indispensable for data-science-related work. Power BI’s ease of use comes from the fact that it
has a drag and drop interface. This feature helps to perform tasks like sorting, comparing and
analyzing, very easily and fast. Power BI is also compatible with multiple sources, including
Excel, SQL Server, and cloud-based data repositories which makes it an excellent choice for
Data Scientists.

1. Overview of Power BI
Overview

Power BI gives the ability to analyze and explore data on-premise as well as in the cloud. Power
BI provides the ability to collaborate and share customized dashboards and interactive reports
across colleagues and organizations, easily and securely.

Source

Power BI’s Components

Power BI consists of various components which are available in the market separately and can be
used exclusively.
Content Source

Choosing which component to work with depends mainly on the project or a team. We, however,
will be working with Power BI desktop since this is a component primarily used for Business
reports generation and desktop creation. Also, all the other works typically begin with Power BI
desktop, where the report creation takes place.

Introduction to Power BI

For a great hands-on introduction on how to navigate the Power BI platform, take DataCamp's
course, Introduction to Power BI.
2. Advantages of using Power BI
Power BI provides certain benefits which make it superior to the existing analytical tools:

 Provides a cloud-based as well as a desktop interface.


 Provides capabilities like data warehousing, data discovery and interactive dashboards.
 Ability to load custom visualizations, and
 Easily scalable across the entire organization.

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.
Source: https://docs.microsoft.com/en-us/learn/modules/get-started-with-power-bi/2-using-
power-bi

Installation

Power BI only runs on Windows Machines. Mac users could spin up a Windows VM in Azure
and load Power BI onto that or use Turbo.net, which can stream Power BI to the Mac directly
from the cloud.

Power BI can be used in two ways:

 As an app from the Microsoft store and just sign in to get started. This is the online
version of the tool.
 Download the software locally and then install it. Make sure you read all the installation
instructions.
Depending upon the choice of product, download the software on to the computer. After
accepting the license agreement, verify the installation by clicking the Power BI Icon/App. If the
following screen appears, you are good to go.

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

The image below highlights the major components of the workspace of Power BI.
Basic Views

 Report View: This is the main view where the Dashboard is created.
 Data View: The data view gives a preview of the entire data.
 Relationship View: The relationship view displays the relationship between various
objects.
Connecting to a Data Source

Power BI can be connected to several data sources. The Get Data icon displays all the possible
available options from where data can be imported into Power BI.
Let’s look at a few of the most commonly used data sources:

 Excel data

Let’s connect to an Excel data source. The workbooks consist of some fake financial data.
Download the file from here. Power BI Desktop loads the workbook and reads its contents, and
shows you the data in the file using the Navigator window.

Once loaded, the data can be viewed in the Fields pane.


 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.

link: https://www.bankrate.com/retirement/best-and-worst-states-for-retirement/

Simply select Web as an option in Get Data and enter the name of the url.
Try experimenting with other data sources too.

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.

Creating a Custom Column

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
OpenAI
Changing Column Data Types

The data types of the columns can also be changed easily. The Units Sold column has a
floating point data type which can be adjusted to a whole number.
Removing Columns

Removing columns is also easy. Simply select the column to be selected and choose the Remove
Columns option, as shown in the following figure. Let’s get rid of the Discount column as it is
adding no value to our dataset.
Similarly, there are other multitudes of functions that can be carried out like removing and
adding rows, transpose, pivot and split which can be easily achieved through the query editor.
Note that all the steps that you undertake to transform your data also appears in the Query
Settings panel.
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.
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 and Profit by Segment
 Sales & Profit by Month
 Sales by Product
 Profit by Discount Band
The Dashboard created is interactive which means a change in one tile affects the other.
8. Power BI’s integration with R & Python
Apart from the various visualization advantages that Power BI offers, it also has an amazing out
of the box connection capabilities. Power BI can easily integrate with languages like Python, R,
and even with DBMS like SQL. This offers increased advantages in terms of functionalities and
comes in handy for Data Scientists who are used to working in Python or R. They can directly
import the R and Python scripts in the workspace and take advantage of its visualizations which
are far more superior than that of these languages.

In this section we shall learn how to work with Python and R scripts in R. For learning about
SQL’s integration with Power BI, here is a detailed article on that:

 SQL with Power BI

Power BI & R

R is a popular statistical language used to perform sophisticated analysis and predictive analytics,
such as linear and nonlinear modeling, statistical tests, time-series analysis, classification,
clustering, etc. Using Power BI in conjunction with R gives the users access to a rich, ever-
expanding collection of statistical analysis and data mining libraries to help them gain deeper
insights from their data.

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

Under Options, go to the R Scripting Tab and make sure you can see the correct R version.
Using R Scripts within Power BI

Working with R Scripts in Power BI is an excellent resource on this topic. Below is an overview
from the same source.

1. R scripts for Importing Data

There may be times when you don’t want to import an entire dataset but a portion of it. You can
write an R script to only select specific columns or rows from the entire dataset to be loaded into
Power BI.
For this demonstration, we will be working with the well known Iris dataset that is included with
the CRAN distribution.

Datasets can also be imported from files. Here is an example which shows how to load a CSV
file into the workspace with the following script. Download the file from here.

iris_csv <- read.csv(file="C:/Users/Parul/Desktop/Iris", header=TRUE, sep=",")


OpenAI
Merely importing data with an R script doesn’t serve much of a purpose. The actual use is when
we can manipulate data while importing. The following script uses the summarize and
group_by functions available in the dplyr R package to group and aggregate the data before
importing it:

Launch R Studio and install the following packages:

install.packages("dplyr")
install.packages("data.table")
install.packages("ggplot2")
OpenAI

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)
iris_mean <- summarize(group_by(iris, Species),
slength = mean(Sepal.Length), swidth = mean(Sepal.Width),
plength = mean(Petal.Length), pwidth = mean(Petal.Width))
OpenAI

2. R scripts for Transforming Data

R scripts come in handy when we want to manipulate data that is already imported into the
workspace. Let’s say we want to apply the summarize and groupby functions after the entire
data has been imported. This can be achieved by running R Script in the Query Editor as follows:
3. R scripts for Creating Visualizations

With the help of R scripts, you can create visualizations in Power BI. Simply type in the script
and load in the necessary libraries, and you get visualizations similar to the ones in any R IDE.
Let’s go through the steps:

 Import the Iris dataset into the workspace.


 Click on the ‘R script Visual’ in the visualization Tab, and a placeholder R visual
image appears on the canvas and a script editor at the bottom.
 Select the fields that you want to include in the script. Let’s select
PetalLengthCm ,PetalWidthCm and Species. The selected fields appear under the
Values Tab, and pre-populated R script appears in the R editor.
 The script creates a dataframe named dataset with the selected columns. You can now
write your script here or make changes in the existing one. Let’s paste the following code
which imports the ggplot library and creates a scatter plot.

library(ggplot2)
ggplot(data=dataset, aes(x=PetalWidthCm, y=PetalLengthCm)) +
geom_point(aes(color=Species), size=2) +
ggtitle("Petal Widths and Lengths") +
labs(x="Petal Width", y="Petal Length") +
theme_bw() +
theme(title=element_text(size=15, color="blue3"))
OpenAI

PowerBI & Python

Python is a widely used general-purpose programming language, and a large number of Python
libraries are available to perform statistical analysis, predictive modeling using machine learning
algorithms.

Microsoft recently made it possible to integrate Python scripts within PowerBI which enables
running Python scripts and obtaining Python visuals within Power BI. Let’s look at the steps
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

Under Options, go to the Preview Features Tab and enable ‘Python Support’.
Restart Power BI and you get the Python icon both in visualization as well as in the Transform
tab.
There are multiple ways of running Python Scripts in Power BI.

1. Running Python scripts exclusively

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.
2. Creating Visualizations using Python

 Import the dataset into the workspace. Going with the same Financial dataset, which
pertains to Financials of a hypothetical company.
 Click on the ‘Python Visuals’ in the visualization Tab and a placeholder Python visual
image appears on the canvas and a Python script editor at the bottom.
 Select the fields that you want to include in the script. Let’s select Sales and Profit.
The selected fields appear under the Values Tab, and the scripts also appears in the
Python script editor.
 The script creates a pandas dataframe named dataset with the selected columns. You
can now write your script here or make changes in the existing one. Let’s paste the
following code which imports matplotlib and creates a plot.

import matplotlib.pyplot as plt


dataset.plot()
plt.title("Sales Vs Profit")
plt.show()
 OpenAI
 Run the script and the visualization appears on the canvas. The visualization appears as it
would in any Python IDLE.
 Next, let’s create a correlation plot. Select Discounts, gross Sales, and Units sold
in addition to the previous fields and replace the script with this new script:

import matplotlib.pyplot as plt


plt.matshow(dataset.corr('pearson'))
plt.show()
 OpenAI
 We can also import other libraries. Let’s import Seaborn library but make sure it is
installed on your system. The dataset is called the ‘Tips’ dataset which usually comes
pre-loaded with seaborn. Download the dataset from here and load it into the workspace.
Then paste the following code into the script editor, and you will get the seaborn plots.

import matplotlib.pyplot as plt


import seaborn as sns
sns.set(style="darkgrid")

sns.relplot(x="total_bill", y="tip", data=dataset)


sns.relplot(x="total_bill", y="tip", hue="smoker", data=dataset);
sns.relplot(x="total_bill", y="tip", hue="smoker",col="time", data=dataset);

plt.show()
 OpenAI
The Dashboard with all the Python visualizations will finally appear like this.
Python Dashboard

9. Saving and Publishing


Saving and Exporting Files

You can save your files as Power BI templates. The visualizations can also be exported as PDF
files.

Publishing

Data is only useful when it can be shared among people or organization. The generated
Dashboard or reports can also be shared by publishing it to the Power BI Service. We can then
use the Power BI Apps to view or interact with the Dashboards/Reports.
10. Conclusion
That’s all we need to know to create a good visualization in PowerBI although, one might find
doing a lot more revising in each stage than we did here. So with experimentation and practice,
Power BI becomes a lot more familiar and will unleash amazing features to help us analyze and
present data

How To Use Power BI: A Step-by-Step


Tutorial


 by Lauren Ballejos, IT Editorial Expertreviewed by Stan Hunter, Technical Marketing Engineer

IT Ops

 Last updated March 18, 2024

Informed decision-making relies heavily on the ability to interpret and derive insights from data.
With the increasing volume and complexity of data in today’s business environment, having a
tool that can transform raw data into meaningful visualizations is crucial. Learn how to use
Power BI – a game-changer in the world of data analysis and reporting.

Microsoft Power BI is a business analytics tool that allows users to visualize data and share
insights across an organization. Whether you’re an analyst, business user, or IT professional,
Power BI provides a unified platform for creating interactive reports and dashboards. It connects
to a wide range of data sources, transforms raw data into actionable information, and facilitates
data-driven decision-making.

This guide is designed for those new to Power BI, covering everything from installation to
creating reports and interactive dashboards. By the end of this tutorial, readers will have gained
an understanding of Power BI interface navigation, importing and managing data, building
reports, and utilizing Power BI for effective data analytics.
Getting started with Power BI
Installing Power BI

To begin your Power BI journey, start by installing the Power BI Desktop application. It’s a free,
standalone application that allows you to create reports and dashboards. Search via your
preferred search engine, download the latest version from Microsoft, follow the straightforward
installation process, and you’ll have the tool ready to use.

Power BI basics
Understanding the Power BI workspace

Grasping the Power BI workspace is fundamental. Learn about datasets, reports, and dashboards.
Understand how they interconnect and how changes in one area affect others. Gain insights into
the relationship between the Power BI Desktop application and the Power BI service.

1. Launch Power BI Desktop after installation.


2. Familiarize yourself with the different sections, including the ribbon, report view, visualization
pane, and fields pane.
3. Understand the concept of datasets, reports, and dashboards in the Power BI workspace.
4. Use the “Get Data” option in the Home tab to connect to a data source, such as Excel, SQL
Server, or an online service.
5. Build a basic report by dragging and dropping fields onto the report canvas. Add visuals like
tables or charts.

Importing data into Power BI

1. Select “Get Data” from the Home tab, then choose the type of data source (e.g., Excel, CSV,
Database) and provide connection details.
2. Transform and load data by using the Power Query Editor to clean, transform, and shape the
data. Click “Close & Apply” to load the data into Power BI.

Creating and managing datasets in Power BI

Datasets in Power BI represent your data source. They can be imported or created within Power
BI.

1. Create a dataset, either by importing data or defining a new dataset, by using the Power BI
Desktop interface.
2. If your dataset includes multiple tables, create relationships between them in the Power BI data
model.
3. Rename fields as required, set data types, and manage properties using the Fields pane.

Exploring the Power BI data model


Understanding your data model means analyzing tables to build a picture of their relationships.
Power BI provides graphical tools to assist in this process.

1. In Power BI Desktop, click on the “Relationships” view to understand how tables are connected.
2. Review the tables and fields in the data model to understand their structure.
3. Utilize DAX (Data Analysis Expressions) to create calculated columns based on existing data.
4. Switch to the “Data” view to see a tabular representation of your data model.

Creating reports in Power BI


Begin the journey into report creation with this step-by-step guide. Learn how to add data to your
report, choose appropriate visualizations, and arrange elements on the canvas. Power BI’s
intuitive interface makes it easy for users to generate reports even with minimal technical
expertise.

Add data to your report

1. Launch Power BI Desktop.


2. Select “Get Data” from the home tab to connect to your data source (e.g., Excel, SQL Server,
CSV).
3. Pick the appropriate data source and provide connection details.
4. Load or transform the data using the Power Query Editor if needed.
5. Click “Close & Apply” to load the data into Power BI.

Choose visualizations

1. Click on the “Report” tab at the bottom to enter the report view.
2. In the Fields pane, drag and drop fields onto the report canvas.
3. Explore the Visualizations pane on the right.
4. Select the type of visualization (e.g., bar chart, line chart) based on your data.

Arrange elements on the canvas

1. Click on a visualization to select it.


2. Resize and move visuals on the canvas as needed.
3. Customize axis titles, legends, and data labels using options in the Visualizations pane.
4. Arrange visuals in a logical order for better storytelling.

Customize report layouts and formatting

1. In the “View” tab, select “Themes” to apply predefined styles or create custom themes.
2. Click on a visual to select it, and use the format pane on the right to customize colors, fonts, and
other visual elements.
3. Customize the report background and add borders if necessary.

Add visualizations, charts, and tables


1. In the Visualizations pane, explore various chart types (e.g., pie chart, scatter plot).
2. Select the visualization type that best suits your data.
3. Drag the selected visualization type onto the canvas.
4. Assign fields to the visualization’s values, axis, and legend.
5. Customize individual visualizations using the Format pane.
6. Adjust settings such as colors, data labels, and tooltips.

Incorporating Power BI analytics features

Power BI includes a number of advanced features that can be used to enhance your reports,
including:

 Advanced analytics: In the Visualizations pane, click on the ellipsis (…) and select “Analytics.”
Enable features such as trendlines, reference lines, and clustering.
 Forecasting: Click on a time-series visualization. In the Analytics pane, turn on the forecasting
option to predict future trends.
 Statistical measures: Utilize statistical measures such as median, variance, or percentiles in the
Analytics pane.
 Insights: Use the “Explain the Increase” or “Find where this distribution differs” features for
deeper insights.

Creating interactive dashboards with Power BI


Dashboards are dynamic, interactive displays of your data. Explore the process of creating
dashboards in Power BI by pinning visuals from reports. Understand the concept of dashboard
tiles and how they can be configured to display real-time data.

How to create interactive dashboards

1. Open Power BI.


2. Choose the workspace where you want to create the dashboard.
3. Click on the “New” button and select “Dashboard.”
4. Provide a meaningful name for your dashboard.
5. Open a report and select the visual you want to add to the dashboard.
6. Click on “Pin Live Page” or “Pin to Dashboard” and choose the dashboard to pin it to.

Adding visuals and reports to dashboards

 In Power BI, open the report containing the visuals you want to add to the dashboard.
 Pin visuals by selecting a visual on the report, click on “Pin Live Page” or “Pin to Dashboard”, and
choose the dashboard where you want to pin the visual.
 Arrange and resize tiles by dragging and dropping them into your desired layout.
 Pin visuals from multiple reports onto the same dashboard for a consolidated view.

Configuring dashboard interactions


1. Enable cross-filtering by clicking on a visual in your dashboard, and selecting “Focus mode” from
the visual’s ellipsis menu, to see the visual in detail. Click on data points to filter other visuals.
2. Set up cross-highlighting by selecting a visual and choosing “Highlight” from the ellipsis menu.
Select data points to highlight related information in other visuals.
3. Configure relationships between visuals in the report to enhance interactivity.

Sharing and collaborating on Power BI dashboards

Sharing and collaboration are where Power BI dashboards truly bring analytics to life. Sharing a
dashboard is as simple as clicking ‘Share’ from within a dashboard. Permissions can be set for
specific users and groups to determine whether recipients can read-only or edit the dashboard.

Publishing a report or dashboard to the Power BI service makes it accessible to those you have
granted permission to, who can access it via a shared link. Users can leave comments against
visuals, enhancing collaboration.

Integrating Power BI with Power Query


Power Query is a crucial element within Power BI, providing data connectivity and
transformation functionality. Effectively utilizing Power Query to connect to diverse data
sources, shape your data, and seamlessly load it into Power BI provides a logical and streamlined
data analytics experience.

 Launch Power Query: Launch Power BI Desktop on your computer, and select the “Home” tab
to access Power Query. Choose “Transform Data” to enter the Power Query Editor.
 Connect to data sources: Within the Power Query Editor, navigate to the “Home” tab and select
“Get Data”. Select the desired data source from the list (e.g., Excel, SQL Server, Web), and enter
connection details, such as server addresses or file paths. Click “OK” or “Connect” to load the
selected data into Power Query.
 Shape the data: Review the loaded data within the Power Query Editor, then clean, filter, and
transform the data as required. Use the “Transform” and “Add Column” tabs to apply
transformations and merge or append multiple queries to consolidate data.
 Load data into Power BI: Return to the “Home” tab in Power Query Editor, and select “Close &
Apply” to load the transformed data into Power BI.
 Synchronize changes: Changes made in Power Query are automatically synchronized with
Power BI, ensuring a consistent user experience.
 Test and validate: Navigate to Power BI Desktop and preview the integrated data, using the
integrated data to create insightful reports and visualizations.

Experiment with diverse data sources and transformations to unlock the full potential of the
dynamic integration between Power BI and Power Query.

Power BI documentation and resources


Power BI offers extensive documentation and learning resources. Take advantage of the official
Power BI documentation, which provides in-depth information on various features and
functionalities. Additionally, explore online forums, blogs, and communities where Power BI
enthusiasts share tips, tricks, and best practices. Some of our favorites include:

 Microsoft Power BI forum: The official community forum hosted by Microsoft for Power BI users.
It includes various categories such as Desktop, Service, Mobile, and more. Users can ask
questions, share ideas, and collaborate with other Power BI enthusiasts. Microsoft experts and
MVPs often participate in discussions.
 Microsoft Power BI blog: The official blog of Power BI by Microsoft. Regularly updated with
official announcements, feature highlights, and case studies. Ideal for staying informed about
the latest in the Power BI ecosystem.
 Power BI Tips: A community-driven website with a focus on Power BI tips, tricks, and best
practices. Users can contribute their tips, access tutorials, and stay updated on the latest Power
BI news.

Realize the potential of Power BI


In this step-by-step guide, we have summarized the fundamentals of Microsoft Power BI for data
analysis and reporting. From the basics of navigating the interface to creating interactive
dashboards and performing advanced analytics, you should now be equipped to take advantage
of Power BI.

Build on this introductory information by experimenting with datasets and visualizations and
creating informative reports and dashboards. The more familiar you become with the capabilities
of Power BI, the more adept you’ll become in transforming data into actionable insights.

Power BI is a versatile and powerful tool, providing powerful analytics features and seamless
integration with other Microsoft products with an intuitive and accessible user interface.
Mastering Power BI puts you at the forefront of modern data analysis and reporting workflows,
empowering your organization with the data analytics and visualizations that inform decision-
making and success

You might also like