Power BI Unit-I
Power BI Unit-I
1|SHK
B.Sc (ECS)-II | Data Visualization Unit - 1
Spot business problems
Identify emerging business and market trends, patterns
Develop stronger business strategies
Higher profit and reduce losses
2|SHK
B.Sc (ECS)-II | Data Visualization Unit - 1
Data visualization using various tools and charts to create performance scorecards and dashboards,
displaying KPIs and business metrics.
Why Power BI:
Access and extracts data from multiple sources like Excel, CSV, XML, JSON, cloud, database etc.
It provides secure and reliable connections to the data sources in the cloud.
Direct queries run on datasets.
Helps to users identify valuable trends and make predictions.
Customized visualization as per user requirement
Quickly search and extract valuable information.
Automatically search hidden insights
Provides a hybrid configuration, quick deployment, and secure environment.
Less expensive
It allows real-time dashboard updates.
It provides pre-built dashboards and reports for SaaS solutions.
Power BI is a Microsoft’s product initially released on 11th July 2011. It was originally designed
and created by Ron George in 2010.
Power BI has been officially declared BI tools by 2019
Power BI is a user-friendly tool offering impressive drag-and-drop features and self-service
capabilities.
3|SHK
B.Sc (ECS)-II | Data Visualization Unit - 1
Power BI dashboards provide a 360-degree view for business users with their most important
metrics, monitor the health of their businesses, updated in real time, and available on all devices.
Microsoft offers three types of Power BI platforms:
Power BI Desktop (A desktop application)
Power BI Service (SaaS i.e., Software as a Service)
Power BI Mobile (For iOS and Android devices)
Features of Power BI
Easy to setup:
You can sign up for free to get started in seconds and start monitoring your data.
Access data from different sources:
To allows gathering business data from a wider range of data sources like SQL, Azure, Excel,
Text, CSV, PDF, Cloud, database, and on-premises data in the form of unstructured and structured.
Real Time reports:
Power BI supports real-time data processing, users can view up-to-date data in their dashboards
and reports.
Customizable Visualizations
Power BI has many built-in visuals to build dashboards and reports as per business needs. Also,
users can download the custom visuals from marketplaces per their requirements.
Natural Language Q&A Question Box
We can interact with Power BI using natural language queries by typing questions in the Q&A
question box like “What are the total sales for the year 2018?” then, it would show the result with a
beautiful visual or chart.
Datasets Filtration
Instead of importing the entire dataset, the user can source a subset of dataset as per the user
requirement.
Data Analysis Expressions (DAX) Function
Data Analysis Expressions (DAX) language to perform advanced calculations, aggregations, and
data manipulations for in-depth analysis.
Data Relationships
User can define the relationship between those tables at least one matching column.
Navigation Panel
The navigation pane provides a hierarchical view of the different elements in a report, helping easy
exploration and navigation between pages and sections.
4|SHK
B.Sc (ECS)-II | Data Visualization Unit - 1
Flexible Tiles
Flexible tiles that can be resized, rearranged, and customized within dashboards, providing us with
the flexibility to design our desired layout.
Informative Reports
Power BI reports allow us to create informative and visually rich presentations of data insights,
enabling effective communication and data-driven decision-making.
Help & Feedback Buttons
Power BI provides accessible help resources and feedback channels to assist us (users) in resolving
issues and provide suggestions for platform improvement.
Office 365 App Launcher
Power BI is integrated with the Office 365 app launcher, allowing users to effortlessly switch
between Power BI and other Microsoft applications.
Power BI Components
1. Power Query
Power Query is a data transformation and ETL (Extract, Transform, Load) tool that allows us to
clean and shape our data before importing it into Power BI. It allows the user to identify, connect,
merge and refine data sources as per the needs of the analysis.
2. Power Pivot
Power Pivot is a data modeling technique that create data models, establishment of relationships
between the data or tables, and define model calculations on simple and complex data using DAX.
3. Power View
Power View is a data visualization tool that allows us to create interactive reports and
visualizations, including charts, tables, and maps, to help us better understand our data. We can
customize the visualizations to meet our specific needs.
4. Power Map
The Power Map creates interactive geographical data visualizations. Power Map is a 3-D data
visualization tool that map your data and plot more than a million rows of data visualization in 3-D
format. Power Map works with Bing maps to visualize based on latitude, longitude, or country,
state, city, and street address information.
5. Data Catalog
Data Catalog helps you to discover the queries and reuse them quickly. To perform the search
function, metadata can be used.
6. Data Management Gateway
Data management gateway joins the data to the cloud. One the data enter to the cloud services it a
refreshers datasets and reflect the visualization more quickly. Data fields can be viewed easily and
expose tables.
7. Power Q&A
It is the fastest way to get an answer from your data using natural language i.e. Ask questions and
5|SHK
B.Sc (ECS)-II | Data Visualization Unit - 1
get immediate answers with natural language query.
8. Power BI Service
The Power Service enables the sharing of workbooks and data views with other users. The data
gets refreshed at regular intervals from the on-premises or/and cloud-based data sources.
9. Power BI Desktop
It is a user friendly development tool for Power View, Power Query, and Power Pivot. You can
import data from a data source, prepare and transform it and use it in visualizations to create
reports in Power BI Desktop.
10. Power BI Website:
It is a web platform to view and share Power BI apps or solutions. You can create dashboards from
reports, share the dashboards with other Power BI users.
Building Blocks of Power BI
Visualizations
Visualization is a graphical representation of data. These help in restructuring the data for a better
understanding. Visualizations make insights easier to understand because understand a picture
faster than grasping a numbers
Example: Pie Chart, Line Graph, Side by Side Bar Charts, Graphical Presentation of the source
data on top of geographical map, tree map etc.
Datasets
Dataset is a collection of data that may be imported or linked. Power BI used to create interactive
reports and dashboards. It can be a filtered collection of data which you combined from multiple
different sources to produce a unique collection that can be used in Power BI.
Example: Excel sheets, CSV,XML, JSON, oracle or sql server tables.
Reports
Report is a collection of visualizations that appear together on one or more pages.
Example: Sales by Country, State, City Report, Logistic Performance Report, Profit report etc.
Dashboards
It is a collection of various data and reports. Dashboard is single layer presentation of multiple
visualization. i.e we can integrate one or more visualizations in to one page layer.
Example: Sales dashboard can have pie charts, geographical maps and bar charts.
Tiles
Each and every visual data stored in the report or dashboards are called a Tile. Dashboard is a
collection of Tiles.
Example: Pie Chart in Dashboard or Report.
Architecture of Power BI
Power BI Architecture can be divided into three main phases. The first two phases use ETL
(extract, transform, and load) process to handle the data.
6|SHK
B.Sc (ECS)-II | Data Visualization Unit - 1
1. Data Integration:
An organization deals with the data that comes from different sources in different file formats.
First, extract the data from different sources which can be your separate database, servers, etc.
The data is integrated into a standard format and stored at a common area called staging area.
2. Data Processing:
The integrated data is not ready for visualization because the data needs processing and
cleansing operations to remove missing values or redundant values. This data is pre-processed.
After the data is cleaned, business rules are applied to the data and it is transformed into
presentable data. This data will be loaded into the data warehouse.
3. Data Presentation:
Once the data is loaded and processed, then it can be visualized with the use of various reports,
dashboards, and visualizations using Power BI Desktop.
These visual reports help business end-users to take business decision based on the insights.
These visualizations can be published on the web or mobile apps for sharing with other users.
Install Power BI Desktop
Power BI desktop is the free tool which you can download and install in your local system.
We can use Power BI desktop to import your data, do the data modelling and then to create
reports and dashboards.
Microsoft Power BI Desktop is available for 32-bit (x86) and 64-bit (x64) platforms. You can
download according to your system requirements.
For my 64 bit machine, I have downloaded the 64-bit version of Power BI Desktop.
Double click on the setup to start the installation. Then click on Next.
7|SHK
B.Sc (ECS)-II | Data Visualization Unit - 1
Then accept the terms and conditions check box and click on Next.
Then select the installation folder and Then click on Install button to start the installation.
9|SHK
B.Sc (ECS)-II | Data Visualization Unit - 1
The Power BI transforms data button will takes data for cleaning and transforming.
Loading or Import Data form CSV:
Load or import data from CSV file. In the menu bar click on ‘Get data menu → Text/CSV’.
Click the Get Data option under the Home tab and select the Text/CSV Option and click the
Connect button.
Once you click the Connect button, a new window opens to select the Text File from our file
system. We are selecting the Employee.txt file, as shown below.
You can now see the preview of the data in the text file.
11 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
Power BI automatically picks the delimiter and separates the columns. If this is not the case, use
the Delimiter option to change as per your requirement.
If you are satisfied with the Data and the data types, click the Load button; otherwise, click the
Edit button to make changes.
Click on the Load button. All the Columns imported from the text file under the Fields section.
When you click the Edit button, the following window opens. Use this window to change the data
as per your requirements.
You can get required data from Excel, CSV, text, PDF file, various relational and non-relational
databases, SharePoint, etc.
12 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
Get Web Page Data into Power BI
The Web Data Source enables you to import data from web pages for analysis purposes. It
completely imports data presented in HTML table format from websites.
Go to the Home Tab, click on Get Data and select Web option.
Power BI Desktop makes the connection to the data source, and it presents the available data sources
in the Navigator.
Select the Table which you want and to load the data, select the Load button at the bottom of the
Navigator pane.
13 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
Navigator Pane
Then, Loaded data in Field Section.
Locate the JSON file that contains your dataset and import it. The first 5 records in our JSON file:
[{
14 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
"Person_Id": 1,
"Person_Name": "Lyle Puckett",
"Person_Age": 37,
"Person_Gender": "0"
},
{
"Person_Id": 2,
"Person_Name": "Abdul Reed",
"Person_Age": 58,
"Person_Gender": "0"
},
{
"Person_Id": 3,
"Person_Name": "Leonard Raymond",
"Person_Age": 30,
"Person_Gender": "1"
},
{
"Person_Id": 4,
"Person_Name": "Louis Hurley",
"Person_Age": 52,
"Person_Gender": "1"
},
{
"Person_Id": 5,
"Person_Name": "Ulysses Ward",
"Person_Age": 50,
"Person_Gender": "0"
},
Each person has four properties, i.e., “Person_Id”, “Person_Name”, “Person_Age”, and
“Person_Gender”.
These properties will be converted into columns. Once the above JSON file is imported, you
should see a list with 100 records.
If you click on any record, you will see the details of one person. You can see the values for the
“Person_Id”, “Person_Name”, “Person_Age”, and “Person_Gender” columns.
15 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
To return to the previous window, click the “X Navigation” button.
To convert the List into the table, click the “To Table” button from the top menu.
Your list will be converted into a table with 1 column. The column contains one record per person,
and each record contains 4 values.
To create 4 columns, click on the “” button at the top right corner of the column name as shown in
the following figure and click the “OK” button.
You JSON will be converted into a table. You can see the four column names that correspond to
the properties in JSON files.
16 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
To create a visualization in the form of a report, you will need to save this table.
Click the “Close & Apply” button. Once you have done that, you will be taken to the Reports View.
From the reports view, select the “Clustered column chart”, as shown in the “Visualization” field
below. Add the “Person Gender” column to the Axis and “Person Age” column to the Value field.
A clustered column chart, such as the one shown below, will be created. The chart shows that the
number of persons with gender id 0 is higher than the ones with gender id 1.
Load Data from PDF file
The Power BI Desktop contains many preview features. These features are not enabled by default.
17 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
In the File menu, go to Options and settings and click on Options.
We need to click on the Preview features menu option to use the PDF connector in data source.
In the preview feature list, enable Get Data from PDF files. We need to restart Power BI to enable
the preview feature. Close Power BI Desktop and re-open it.
Go to Get Data, you can get a “PDF” option under ‘File’ as a data source.
Once you click on Connect and provide path of this PDF file from a local directory
It connects to PDF file and opens a Navigator. It lists out the table from PDF and a list of all
pages. If we select the page, it shows the complete page content in the Navigator preview window.
18 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
We need to get data from this table, therefore, put a check in front of the table, and it shows the
table on the right-hand side page.
We can choose the required fields from this data set and create a Power BI Visualization.
Once you click the Connect button, you should see the following error.
To connect Power BI with MySQL Server you need to install a driver that acts as a connector
between Power BI and MySQL Server.
To download the driver, click on the “Learn more” option in the above screenshot or you can
simply go to this link: https://dev.mysql.com/downloads/file/?id=412152
19 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
Click the “No thanks, just start my download” link highlighted in yellow below, to download the
connector.
Open the downloaded executable file for the connector. Click the ‘Next’ button.
You will see the following three download options. You can select any of them.
For this article, we will use the “Custom” download option and click the Next button.
20 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
Finally, to install the connector, click the Install button.
Once the installation is completed successfully, you should see the following dialogue box. Click
the Finish button.
Restart Microsoft Power BI and again select MySQL database from the list of data sources.
Click the Connect button.
Enter the name of MySQL Server and database name that you want to import from and click the
OK button.
MySQL only have the option to import the data image and you cannot execute direct queries on the
dataset.
Enter the user name and password that you use to access your MySQL Server.
You will be connected to the MySQL Server and your Server and database names will be visible in
the navigator.
You will also be able to see all of the tables in your database. Only one is showing below as our
dummy database only has one small table in it.
To import the dataset from the students table, tick the checkbox next to the students table and click
the Load button.
21 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
I’ve selected a “Clustered column chart”. The Gender of students will be used for the x-axis while
the values shown will be the students’ average ages.
The output shows that on average, female students are slightly older than male students.
Refreshing Data
Data refresh is the process of updating data in Power BI with the latest data from the data source.
When imported data or dataset, data source is updated frequently.
Data refresh also ensures that the data in the dataset is updated with the latest changes made to the
data source.
22 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
Transforming Datasets:
Editing Data After a Data Load, Transforming Data Before Loading, Dataset Shaping-Renaming
Columns, Reordering Columns, Removing Columns, Merging Columns, Duplicating Columns,
Splitting Columns, Removing Records, Removing Duplicate Records, Sorting Data, Reversing the
Row Order, Filtering Data-Selecting Specific Values, Finding Elements in the Filter List, Filtering
Text Ranges, Filtering Numeric Ranges, Filtering Date and Time Ranges
*********************************************************************************
Data transformation and cleansing are essential steps in the data editing process in Power BI. To
effectively transform and cleanse your data:
Analyze data and identify any inconsistencies, errors, or missing values.
Remove duplicate rows, fix formatting issues, and correct any data errors.
Apply transformations such as merging datasets, splitting columns, or creating calculated
columns to prepare your data for analysis.
Handling missing data, either by imputing values or excluding incomplete records.
Ensure consistent formatting, units, and naming conventions across your datasets.
To effectively transform and cleanse data in Power BI:
Utilize data cleansing tools and functions provided by Power BI to automate the process.
Regularly review and update your data cleansing steps to maintain data accuracy.
Document your data transformation and cleansing process for future reference and
collaboration with team members.
Editing Data after a Data Load
If you want to make some changes like rename, delete, add column in the already loaded data.
First, you saved this file with .pbix extension in the disk.
1. Open the Power BI sample file
2. Click the Edit Queries option. The Power BI Desktop Query Editor will open and display
the source data as a table.
3. Right-click the title of the CostPrice column. The column will be selected.
6. In the Power BI Desktop Query Editor Home ribbon, click the Close and Apply button.
The Power BI Desktop Query Editor will close and return you to the Power BI Desktop window.
VehicleCost has replaced CostPrice anywhere that it was used in the dashboard.
23 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
Transforming Data before Loading
A simple modification to the data before loading the dataset into the Power BI Desktop data model.
To transform your data before it appears in the Power BI Desktop Window:
1. In the Power BI Desktop Home ribbon, click the Get Data button.
2. Select Excel in the menu and Open the Excel file CarSalesFirstDashboardData.xlsx.
3. In the Navigator window, select the CarSalesData worksheet.
4. Click the Edit or transform data button. The Power BI Desktop Query Editor will open
and display the source data as a table.
5. To rename the CostPrice column as VehicleCost.
6. In the Power BI Desktop Query Editor Home ribbon, click the Close and Apply button.
The Power BI Desktop Query Editor will close and return you to the Power BI Desktop app.
Enter Data:
Using this option, you can add directly data in table without use of data source.
You should create a simple table with some columns and rows.
24 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
Enter new columns and rows of data. You can also assign table a name. Ex: Orders.
Click Load to load the data to the Power BI desktop, or Edit to open the Edit Queries window.
Here we will open the Edit queries window.
To add/remove/change the table and data, under Applied Steps, click the icon next to Source:
The same window will open, allowing you to change the table:
It retrieves information about the data, allowing you to start refining it.
1. The ribbon now showcases numerous active buttons that facilitate interaction with the data within
the query.
25 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
2. On the left pane, a list of queries is presented, enabling selection, viewing, and shaping options.
3. in the center pane, the data and also use for shaping and manipulation.
4. The Query Settings pane is visible, detailing the properties and applied steps of the query.
To rename the columns in a table, right-click on the column that you want to rename will open
the context menu. Select the Rename option. Ex: Renamed column CostPrice to VehicleCost
The column will now have a new title. The Applied Steps list on the right will now contain
another element, Renamed Columns. This step will be highlighted.
26 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
Reordering columns
The column order is important because, when you have a large dataset with many columns, the
order of those columns can impact the speed and performance of your report.
Reorder the columns in a logical and efficient order, which can improve the performance of your
report.
It easier for users to navigate and understand your data for better insights and decision-making.
Removing columns
The dataset contains a variety of columns that are irrelevant or redundant, such as missing values,
extra data points, or unimportant categories.
To remove all these unnecessary columns and improve the speed or performance of your reports.
Also saves the analysis time.
Deleting columns can also help you maintain the accuracy and integrity of your data.
You can ensure that your data is accurate, reliable, most relevant and up-to-date information.
Delete a column or series of columns:
1. Click inside the column you want to delete, or if you want to delete several columns at once,
Ctrl-click the titles of the columns that you want to delete.
2. Click the Remove Columns button in the Home ribbon.
28 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
Remove Other Columns:
This option is used to remove all the columns from the table except the selected columns.
Ex: selecting the Percentage and Result column and select the Remove Other Columns option
from the context menu.
Splitting Columns:
Columns are an essential element of data analysis. They contain information that we need to
manipulate and analyze in order to draw conclusions
If the information in a column is not well-organized or if we need to extract specific pieces of data
from a single column, which can be especially useful when filtering or sorting data.
Splitting columns can help restructure information into a more organized format that is easier to
read and analyze.
It can help to reduce the amount of data duplication and create a more restructured and efficient
data model.
Example: you can split a column that contains a date and time into separate columns for the date
and time
If you have multiple values in cells that you want to split out into either rows or columns, you can
use the ‘split column’ feature in Power Query.
The values in each cell can be split by a delimiter, e.g. comma, semicolon, etc.
To split each reference into separate rows, in the ‘Home’ section on the top ribbon, we will click
on the ‘Split Column’ button and choose ‘By Delimiter’.
We will then need to choose which delimiter to split the values by.
There is more than one delimiter in each cell, we will choose to split for each occurrence of the
delimiter.
30 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
We want is to split the Timestamp column into Date and Time column.
1. Select the column “Right-Click” on the column heading.
2. A drop-down list will appear; select “Split Column.”
3. Then we go for “By Delimiter” to split the column.
Removing rows/records
Deleting rows is an essential task for data cleaning and analysis.
If you want to miss or corrupted data, remove duplicates, remove unwanted or irrelevant data.
This method allows you to remove unwanted or irrelevant rows one at a time.
Removing these rows can improve the accuracy of your analysis and make it more user-friendly.
To allow you to reduce the size of the dataset, Power BI Desktop offers two basic approaches:
1. Keep Rows is used to keep the top N number of rows in a table.
2. Remove Rows is used to remove or delete the N rows in a selected table.
Six different types of row removals:
Remove Top Rows: It removes Top N number of rows from this table.
1. Go to ‘Home Tab’ and select ‘Remove rows’, click on the ‘Remove Top Rows’ drop-down
menu. I have 19 rows in my table.
31 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
I have entered 6. I have also highlighted the first six rows. After click on ‘Ok,’ the top two rows
have removed now I have only 13 rows in my table.
Remove Bottom Rows: It removes the N rows from the Bottom of this table.
Enter the number of rows that you want to remove from the bottom. I have entered 10. Click on ‘Ok’, and
your last two lines will be removed.
Remove Alternate Rows: It deletes the rows based on the pattern. It takes three rows as inputs:
First row to remove
Enter the row number (index or position) to remove start.
Number of rows to remove
Enter the number of rows you want to remove each time.
Number of rows to keep enter the number of rows you want to keep.
Remove Duplicates: It removes rows containing duplicated values in the currently selected
columns. All duplicate records are deleted and Removed Duplicates are added to the Applied
Steps list.
32 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
This will automatically remove all of the blank rows in the table:
This results in empty rows being deleted. Removed Blank Rows is then added to the Applied
Steps list.
Remove Errors: removes rows that contain errors within a specified columns
Sorting Data
To sort the data in ascending or descending order.
To sort data in Power BI using different techniques, such as sorting by columns, values, date, and
time, custom sort orders, sorting pivot tables and adding interactive sorting etc.
Sort By Column feature is allows you to quickly identify trends and patterns in your data
You can deselect all items by clicking the (Select All) check box; reselect all the items by
selecting this box again.
If you want to keep only a few elements, it may be faster to unselect all of them first and then
only select the ones that you want to keep.
If you want to exclude any records without a value in the column that you are filtering on then
select Remove Empty from the filter menu.
Finding Elements in the Filter List:
Scrolling up and down in a filter list is time consuming. A fast way of finding a subset of
available elements from the list.
1. Click the pop-up menu for a column. Then filter menu appears.
2. Enter a letter or a few letters in the Search box. The list shortens with every letter or number that
you enter. If you enter ‘an’, then the filter popup will look
34 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
To remove a filter, click the cross that appears at the right of the Search box.
Filtering Text Ranges:
If a column contains text, then you can apply Number Filters options to filter the data.
Filter Option Description
Equals Sets the text that must match the cell contents.
Does Not Equal Sets the text that must not match the cell contents.
Begins With Sets the text at the left of the cell contents.
Does Not Begin With Sets the text that must not appear at the left of the cell contents.
Ends With Sets the text at the right of the cell contents.
Does Not End With Sets the text that must not appear at the right of the cell contents.
Contains You enter a text that will be part of the cell contents.
Does Not Contain You enter a text that will not be part of the cell contents.
Result:
35 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
Result:
Result: all instances of null values have now been substituted with the value 0.
The sorted sheet after removing all the unnecessary rows will look like this.
39 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
See the report section I have select month then it in pivot Format.
Unpivot Column: Unpivot means turning Attributes, Values columns into the rows.
Grouping Records
Grouping data is the process of organizing similar data into groups.
This feature in Power BI organize and summarize large amounts of data based on specific criteria
or aggregate functions like average, count, min, max etc.
It highlight the relationships between different groups of data.
Grouping helps to categorize data and present it easier to visualize.
In power query, Go to Home ribbon, click the Group By button.
40 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
Example: you can group sales data by region and calculate the total sales for each region.
Advantages of grouping data in Power BI are:
Enhances data analysis and understanding
Allows for easy identification of trends, patterns, and outliers
Simplifies data interpretation
Helps in faster decision-making
Improved visualizations
Conditional Column
The conditional Column is similar to the IF-Else statement in Excel. It generates columns
according to conditions and specified logic.
Example:
We want to specify the country abbreviations according to the group they are in.
We want to select the USA for all the groups named ‘North America.’
1. Go to “Add Column.”
2. Select “Conditional Column.”
3. ‘Add Conditional Column’ page will appear, where you will specify the conditions.
4. To give a name to a new column; by default, it sets the name as Custom.
5. Fill in the condition according to your need and click on “OK.”
42 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
Creating a Data Model:
Data Modeling in the Power BI Desktop Environment-The Power BI Desktop Data View, Data
Models, Managing Power BI Desktop Data- Manipulating Tables, Manipulating Columns, Power
BI Desktop Data Types, Formatting Power BI Desktop Data, Currency Formats, Preparing Data for
Dashboards, Categorize Data, Apply a Summarization, Define Sort by Columns, Sorting Data in
Power BI Desktop Tables, Adding Hierarchies, Designing a Power BI Desktop Data Model- Data
View and Relationship View, Creating and Deleting Relationships Manually and Automatically.
*******************************************************************************
Data modeling:
Data Modelling is the process of defining relationships between different data tables to create a
unified and meaningful view of the data. i.e. logical or structured representation of data.
It is a collection of tables and relationships between them that are used to create reports and
visualizations.
A data model shows how data elements are interact with each other.
Data modeling is building effective and insightful reports and dashboards.
It involves shaping and transforming your data.
The purpose of data modeling is to create a structured, optimized, and meaningful representation of
your data to support effective analysis, reporting, and visualization.
It involves transforming raw data into a structured format that can be easily analyzed and visualized
Data Modeling in the Power BI Desktop Environment:
Finding, editing, and loading the source data using queries is preparing your data for the data model.
The Power BI Desktop Data View
To start using Power BI Desktop for data modeling:
Home ribbon is mainly used when creating reports and dashboards
Modeling ribbon is used to categorize and organize data and tables as well as adding calculated
columns and additional metrics.
The Power BI Desktop Data View is also different from the Power BI Desktop Query Editor
In Data View we are looking at all your data. The Query window only always shows a sample of
data.
Power BI Desktop Query is for finding, filtering and mashing up data and Data View is for
refining and calculating the metrics in your data model.
Button Description
Manage Relationships Join tables as well as delete these joins and modify them.
43 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
New Measure Used to add a new value or calculation to a table.
New Column Adds a new calculated column to a table.
Sort By Column Sorting by column data.
Data Type Define the data type for a column.
Format Specify how numbers are formatted.
Home Table Select the table that will contain a measure.
Data Category Allows you to define that a certain column is of a specific category.
It is mostly used with geographical data for mapping.
Default Summarization Default aggregation that is applied in dashboard visualizations.
Managing Power BI Desktop Data:
Manipulating Tables
Preparing data for business intelligence is manipulating the data into standard formats.
Rename tables: To rename a table that you previously imported.
1. Right-click the table name.
2. Select Rename.
3. Enter the new name or modify the existing name.
4. Press Enter.
Manipulating Columns
Renaming a Column:
To rename the column names in an existing table.
Renaming columns can help with data modeling and creating relationships between tables.
When working with multiple tables, it is essential to consistent and descriptive column names
to ensure the relationships between tables.
Renaming columns can also help with data aggregation and visualization, allowing for more
meaningful and informative labels on charts and graphs.
44 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
In the Data pane, right-click on the column/field you want to rename and select "Rename."
This will go to the field into the Edit mode, where you can change the name.
When you insert desired data into the visual, click on the dropdown menu on a specific field
and select "Rename for this visual," the name you type in will affect that visual in particular.
Deleting Columns
The data may contain a variety of columns that are irrelevant or redundant, such as missing
values, extra data points, or unimportant categories.
To remove all these unnecessary columns. Deleting columns can also help you maintain the
accuracy and integrity of your data.
1. Right-click the title of the column that you wish to delete.
2. Select Delete Columns from the context menu. Unless the column is empty,
45 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
Fixed decimal The decimal separator is fixed in place To list the heights of all the
number for Fixed Decimal Number data types. students in a classroom. 2
There are always four digits to the decimal points of accuracy shall
right of the decimal separator, be enough.
allowing for 19 significant digits.
Whole number Represents whole numbers without Product IDs, employee numbers,
any decimal places. or serial numbers.
46 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
suitable for date-based analysis
like daily sales.
Time Time represents just the time. It does Applied when you need to work
not have any digits to the left of the with times of day independent of
decimal place specific dates, like measuring
response times.
Date/Time/Timezone The data type represents the time and Useful for working with date and
timezone value. This same value can time data that includes timezone
be converted into the date and time information, valuable for
model when formatted. international reporting.
Duration Duration indicates a specific length of Measuring the length of time
time, it transforms into a Decimal intervals, like time spent on tasks
Number type. or project durations.
True/False (Boolean) Boolean data types can have one of For representing binary, yes/no,
two values: True or False. or true/false data, often used in
filtering or flagging records.
Binary The Binary data type is used to store Utilized for storing binary data,
binary data, such as images, like images, documents, or other
documents, or any non-textual non-text data in a binary format.
information. It serves as a storage
mechanism for non-text data and is
often used for purposes like document
management and retrieval.
47 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
Formatting Power BI Desktop Data
It allows you to apply formatting to the data in the tables.
When you format the data in the Power BI data model, you are defining the format that will be used
in all visualizations in all the dashboards that you create using this metric.
Currency Formats:
Power BI Desktop will provides a wide range of currency formats. To choose the currency that you
want:
49 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
2. Apply a Default Summarization
When we are creating dashboards, you are frequently grouping numeric data.
It is a process of summarizing large volumes of data into meaningful and manageable insights.
Power BI provides several summarization techniques like sum, average, count, and minimum
and maximum values.
In the Modeling ribbon, click the pop-up to the right of the Default Summarization button and
select option from the menu.
Option Description
Do Not Summarize Column data is not summarized
Sum Column data is summed
Average Return average value of column
Minimum Return minimum value of column
Maximum Return maximum value of column
Count Return number of elements in the column
Count (Distinct) Return number of individual (distinct) elements in the column
3. Define Sort by Columns:
Custom sorting in Power BI refers to the ability to arrange data in a specific order that is not
based on traditional sorting methods, such as alphabetical or numerical order.
To sort data in a dashboard visualization based not on the contents of the selected column, but
by the contents of another column.
The field itself can be sorted based on another column is called as Sort By Column.
By sorting columns in the desired order, users can enhance data visualization and understanding,
reports and dashboards.
This feature allows users to define their own sorting logic based on their unique requirements.
Example: A table contains the month for a sale. If you want to sort a column month name to be
sorted by values of another column month number
In the Modeling ribbon, click the Sort By Column button and select MonthNum from the list of
available columns.
50 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
The dataset has Month and Sales. The Month values in text, not numbers.
A line chart, the Month column is on the X-axis and Sales on the Y-axis.
By default, the visualization sorts by the monthly sales value, which makes a confusion of the
month order along the X-axis. The visualization is misleading.
You might try to fix the month sort by resorting on the visualization as follows:
1. Click the More Options icon, which is the three dots at the top or bottom right of your visualization.
2. Choose Sort Axis.
3. Choose Month from the submenu to resort the X-axis — the months.
It showing ups and downs.
Power BI sorted the months alphabetically and in descending order. the results are misleading.
We need to sort months chronologically in order to get meaningful results.
Sorting Data in Power BI Desktop Tables
To sort the data in ascending or descending order.
To sort data in Power BI using different techniques, such as sorting by columns, values, date, and
time, custom sort orders, sorting pivot tables and adding interactive sorting etc.
Sort By Column feature is allows you to quickly identify trends and patterns in your data
1. Right-click inside the column you want to sort data by.
2. Click the Sort Ascending option in the context menu to sort this column in ascending.
Adding Hierarchies
A hierarchy is creating logical groups of data that are organized by category and level.
It consists of a set of ordered levels.
It allows to navigate and analyze large volumes of data.
By using hierarchies, end-users can easily drill down into the data and have a quick overview and a
better understanding.
Users can quickly drill down into specific areas of interest and identify key trends and insights.
Hierarchy provides a structure for effective data analysis and visualization of complex data sets.
51 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
It also helps to improve your reports and dashboards.
To create a hierarchy:
1. Switch to Report View.
2. Right-click on the field that will become the top-level element in the new hierarchy.
3. Select New Hierarchy. A new hierarchy named Make Hierarchy will appear in the table.
4. Drag the Model field onto the new hierarchy.
Drag the hierarchy on to the report canvas to create a table that is based on the multiple elements that
make up the hierarchy. They are particularly useful as the basis for matrices and drill-down charts.
1. To create a hierarchy
Make as level-1
Model level-2
Vehicle_Type as level-3
2. Right-click on the field you want to set as level 1 of the hierarchy in the fields list.
3. Select Create Hierarchy.
4. A new hierarchy created named your field name “Car Hierarchy”.
A Make field inside the hierarchy is reference to the original category column. Its not a new column
or duplicate.
5. To add another level to the hierarchy, just drag Model to the Category Hierarchy header or right-
click on the Model and use Add to hierarchy.
This adds that field as the second level of the hierarchy; a third level of the hierarchy;
If you want to rename the hierarchy, you can do it by renaming the Category Hierarchy itself. If you
want to change the order of levels, you can drag and drop them over each other.
52 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
Hierarchy can be used for data exploration. With a structure like the above hierarchies, you can easily
drill down or up from a level to another level.
Designing a Power BI Desktop Data Model
After importing data, if dataset is ready for initial use for self-service BI
A data repository is to create and manage relationships between tables.
To define a relationship, two tables having a common field (column) or feature.
To developing a high-performance data model for self-service business intelligence (BI).
Table relationships are links between tables that allow columns in one table to be used in another
table.
Example: one table with customer names and another with their orders, relationships allow you to
see which customers made which orders.
Data models that contain data from multiple tables that must be connected through relationships.
Data View
Data view helps you review, explore, and understand data in your model.
Data view shows data after it's loaded into the model, the Data view icon isn't visible if all data sources are
based on DirectQuery.
1. Data view icon: Select this icon to enter Data view.
2. Data Grid: This area shows the selected table and all columns and rows in it. Columns hidden from
the Report view are greyed out. You can right-click on a column for options.
3. Formula bar: Enter DAX formulas for Measures and Calculated columns.
4. Search: Search for a table or column in your model.
5. Fields list: Select a table or column to view in the data grid.
53 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
Relationship View:
Power BI will automatically try to detect relationships between tables based on common column if any
exists. It discovers as keys.
Example: The productKey column in the Product Details table is connected to the productKey column in
the SalesData Table. Similarly, the Sales Data table and Calendar table are being joined together by the
date and the date columns. Columns that join tables together through foreign keys and primary keys.
Relationship View offers the ability to create multiple data model schemas.
54 | S H K
B.Sc (ECS)-II | Data Visualization Unit - 1
The autodetect feature will automatically create a relationship between both tables based on
the ‘Product’ column.
Now, right-click on the yellow-highlighted relationship line and select ‘Delete.’ After, click
on ‘Manage relationships.’ No relationships between both tables. click on the ‘Autodetect’ button.
Edit a relationship
Way-1: Go to Modeling tab in Power BI header menu > select Manage Relationships >
In the Manage relationships dialog box, select the relationship, and then select Edit.
Way-2: Inside Model view double click on Relationship line >Edit relationships dialog box appears.
Way-3: Inside Model view > Click on Home tab, select Manage Relationships > In the Manage
relationships dialog box, select the relationship, then select Edit.
After the ‘Create Relationship’, select both tables in each dropdown and choose
the ‘Product’ column from both tables, then click on the ‘OK’ button.
Way-2: Go to Modeling tab in Power BI header menu > select Manage Relationships >
In the Manage relationships dialog box, then select New.
Delete Relationship:
-Under Model view, right click on Relationship line and select Delete.
-Delete through Mange Relationships dialog box.
56 | S H K