0% found this document useful (0 votes)
4 views26 pages

Unit 2

Uploaded by

rastley37
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views26 pages

Unit 2

Uploaded by

rastley37
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

UNIT-2

Import Data in Power BI: Data from


files, Data from relational Data
sources, Data from a No SQL database,
Data from online services, Create
dynamic reports with parameters,
Clean and transform the data.
Import Data in Power BI: Data from files
 Organizations often export and store data in files. One
possible file format is a flat file.
 A flat file is a type of file that has only one data table
and every row of data is in the same structure.
 The file doesn't contain hierarchies. Likely, you're
familiar with the most common types of flat files,
which are comma-separated values (.csv) files,
delimited text (.txt) files, and fixed width files.
 Another type of file would be the output files from
different applications, like Microsoft Excel workbooks
(.xlsx).
Import Data in Power BI: Data from files
 Power BI Desktop allows you to get data from many
types of files. You can find a list of the available
options when you use the Get data feature in Power BI
Desktop
 The Home tab, select Get data. In the list that displays,
select the option that you require, such as Text/CSV or
XML. For this example, you'll select Excel.
 After the file has connected to Power BI Desktop, the
Navigator window opens. This window shows you the
data that is available in your data source. Select a table
or entity to preview its contents, to ensure that the
correct data is loaded into the Power BI model.
Import Data in Power BI: Data from files
 Select the check box(es) of the table(s) that you want
to bring in to Power BI. This selection activates the
Load and Transform Data buttons as shown in the
following image.
 Select the Load button to automatically load your data
into the Power BI model or select the Transform Data
button to launch the Power Query Editor, where you
can review and clean your data before loading it into
the Power BI model.
 Often recommend that you transform data, but that
process will be discussed later in this module.
Import Data in Power BI: Data from files
 To change the location of a source file for a data
source during development, or if a file storage location
changes.
 To keep your reports up to date, you'll need to update
your file connection paths in Power BI.
 Power Query provides many ways for you to
accomplish this task, so that you can make this type of
change when needed.
 Data source settings
 Query settings
 Advanced Editor
Import Data in Power BI: Data from files
 Select Data source settings in Power Query.
 In the Data source settings window, select your file
and then select Change Source. Update the File path or
use the Browse option to locate your file, select OK,
and then select Close.
Data from relational Data sources
 Organization uses a relational database for sales, you
can use Power BI Desktop to connect directly to the
database instead of using exported flat files.
 Connecting Power BI to your database will help you to
monitor the progress of your business and identify
trends, so you can forecast sales figures, plan budgets
and set performance indicators and targets.
 Power BI Desktop can connect to many relational
databases that are either in the cloud or on-premises.
 the Get data feature in Power BI Desktop and select
the applicable option for your relational database. For
this example, you would select the SQL Server option
Data from relational Data sources
 Next step is to enter your database server name and a
database name in the SQL Server database window.
The two options in data connectivity mode are: Import
(selected by default, recommended) and Direct Query.
Mostly, you select Import. Other advanced options are
also available in the SQL Server database window
 your server and database names, you'll be prompted to
sign in with a username and password. You'll have
three sign-in options:
 Windows - Use your Windows account (Azure Active
Directory credentials).
Data from relational Data sources
 Database - Use your database credentials. For instance,
SQL Server has its own sign-in and authentication
system that is sometimes used. If the database
administrator gave you a unique sign-in to the
database, you might need to enter those credentials on
the Database tab.
 Microsoft account - Use your Microsoft account
credentials. This option is often used for Azure
services.
 Select a sign-in option, enter your username and
password, and then select Connect.
Data from relational Data sources
 After the database has been connected to Power BI
Desktop, the Navigator window displays the data that
is available in your data source (the SQL database in
this example).
 You can select a table or entity to preview its contents
and make sure that the correct data will be loaded into
the Power BI model.
 Select the check box(es) of the table(s) that you want
to bring in to Power BI Desktop, and then select either
the Load or Transform Data option.
 Load - Automatically load your data into a Power BI
model in its current state.
Data from relational Data sources
 Transform Data - Open your data in Microsoft Power
Query, where you can perform actions such as deleting
unnecessary rows or columns, grouping your data,
removing errors, and many other data quality tasks.
 Can import data is to write an SQL query to specify
only the tables and columns
 To write SQL query, on the SQL Server database
window, enter server and database names, and then
select the arrow next to Advanced options to expand
this section and view options. In the SQL statement
box, write query statement, and then select OK.
Data from relational Data sources
 After you create a data source connection and load
data into Power BI Desktop, can return and change
connection settings at any time. This action is often
required due to a security policy within the
organization, for example, when the password needs to
be updated every 90 days. You can change the data
source, edit permissions or clear permissions.
 On the Home tab, select Transform data, and then
select the Data source settings option.
 From the list of data sources that displays, select the
data source that you want to update.
Data from relational Data sources
 Then, can right-click that data source to view the
available update options or you can use the update
option buttons on the lower left of the window. Select
the update option that you need, change the settings as
required, and then apply your changes.
 can also change your data source settings from within
Power Query. Select the table, and then select the Data
source settings option on the Home ribbon.
Alternatively, you can go to the Query Settings panel
on the right side of the screen and select the settings
icon next to Source (or double Select Source). In the
window that displays, update the server and database
details, and then select OK.
Data from relational Data sources
 Then, can right-click that data source to view the
available update options or you can use the update
option buttons on the lower left of the window. Select
the update option that you need, change the settings as
required, and then apply your changes.
 can also change your data source settings from within
Power Query. Select the table, and then select the Data
source settings option on the Home ribbon.
Alternatively, you can go to the Query Settings panel
on the right side of the screen and select the settings
icon next to Source (or double Select Source). In the
window that displays, update the server and database
details, and then select OK.
Data from a No SQL database

 Some organizations don't use a relational database but


instead use a NoSQL database.
 A NoSQL database (also referred to as non-SQL, not
only SQL or non-relational) is a flexible type of
database that doesn't use tables to store data.
 The application uses Cosmos DB, a NoSQL database,
as the data repository. Data is stored as JSON
documents, which are open standard file formats that
are primarily used to transmit data between a server
and web application.
Data from a No SQL database

 The Get data feature in Power BI Desktop. However,


this time you'll select the More... option to locate and
connect to the type of database that you use. In this
example, you'll select the Azure category, select Azure
Cosmos DB, and then select Connect.
 On the Preview Connector window, select Continue
and then enter your database credentials
 If you're working with data stored in JSON format, it's
often necessary to extract and normalize the data first.
This is because JSON data is often stored in a nested
or unstructured format, which makes it difficult to
analyze or report on directly.
Data from a No SQL database

 connected to the database account, the Navigator


window opens, showing a list of databases under that
account. Select the table that you want to import. In
this example, you'll select the Product table. The
preview pane only shows Record items because all
records in the document are represented as a Record
type in Power BI.
 Select the Edit button to open the records in Power
Query.
Data from a No SQL database

 In Power Query, select the Expander button to the right


side of the Column1 header, which displays the
context menu with a list of fields. Select the fields that
you want to load into Power BI Desktop, clear the Use
original column name as prefix checkbox, and then
select OK.
 Review the selected data to ensure that you're satisfied
with it, then select Close & Apply to load the data into
Power BI Desktop.
 The data now resembles a table with rows and
columns. Data from Cosmos DB can now be related to
data from other data sources and can eventually be
used in a Power BI report.
Data from online services

 To support their daily operations, organizations


frequently use a range of software applications, such
as SharePoint, One Drive, Dynamics 365, Google
Analytics and so on. These applications produce their
own data. Power BI can combine the data from
multiple applications to produce more meaningful
insights and reports.
 By selecting the Get data feature in Power BI Desktop.
Then, select the option that you need from the Online
Services category. In this example, you select
SharePoint Online List.
Data from online services

 After you've selected Connect, you'll be asked for your


SharePoint URL.
 This URL is the one that you use to sign into your
SharePoint site through a web browser.
 Copy the URL from your SharePoint site and paste it
into the connection window in Power BI. You don't
need to enter your full URL file path;
 Load your site URL because, when you're connected,
you can select the specific list that you want to load.
Create dynamic reports with parameters

 Dynamic reports are reports in which the data can be changed


by a developer according to user specifications. Dynamic
reports are valuable because a single report can be used for
multiple purposes. If you use dynamic reports, you'll have
fewer individual reports to create, which will save
organizational time and resources.
 Creating dynamic reports allows you to give users more power
over the data that is displayed in your reports; they can change
the data source and filter the data by themselves.
 To create a dynamic report, you first need to write your SQL
query. Then use the Get data feature in Power BI Desktop to
connect to the database.
Create dynamic reports with parameters

 In the SQL Server database window, select Advanced options.


 Write the SQL query into the SQL statement box and then
select OK.
 Select Edit to open the data in Power Query Editor
create the parameter by following these steps:
 On the Home tab, select Manage parameters > New parameter.
 On the Parameters window, change the default parameter
name to something more descriptive so that its purpose is
clear.
 Select Text from the Type list and then select Any value from
the Suggested value list.
 Select OK.
Create dynamic reports with parameters

To adjust the code in SQL query to assess your new


parameter
 Right-click Query1 and then select Advanced editor.
 Replace the existing value in the execute statement with
an ampersand (&) followed by your parameter name
 Make sure that no errors are shown at bottom of the
window and then select Done.
 To confirm that the query was run, you can run a test by
selecting the parameter query and entering a new value
in the Current Value box. A warning icon might display
next to the query. If so, select that query to view the
warning message, which states that permission is
required to run this native database query.
Create dynamic reports with parameters

 Select Edit Permission and then select Run.


 Select Close and Apply to return to the report editor.
Apply the parameter to the report:
 Select Edit queries > Edit parameters.
 On the Edit Parameters window, enter a new value and
then select OK.
 Select Apply changes and then run the native query
again.
Clean and transform the data

 To clean and transform data in Power BI, you use the


Power Query Editor, a versatile tool for data preparation.
 Start by loading your dataset into Power BI via the Get
Data option, selecting the data source, and choosing to
either load or transform the data directly.
 Once in the Power Query Editor, you can perform various
cleaning tasks such as removing unnecessary columns,
renaming them for clarity, and eliminating duplicate rows.
 Handling missing data is crucial; you can replace null
values with meaningful data or remove rows containing
blanks. Adjusting data types ensures consistency, while
filtering rows or splitting columns allows for precise
structuring.
Clean and transform the data

 group data for aggregation, pivot or unpivot columns


to restructure the table, and create conditional
columns based on logical criteria. Each
transformation step is tracked in the Applied Steps
pane, where you can review, modify, or remove steps
as needed.
 Once satisfied with the changes, click Close & Apply
to reflect the cleaned and transformed data in your
Power BI workspace. This systematic approach
ensures your data is accurate and well-prepared for
analysis.

You might also like