Power BI Question Bank
Power BI Question Bank
2 Marks
1. Difference between Power BI and Tableau
Both Tableau and Power BI are the current IT industry's data analytics and visualization giants. Yet,
there are a few significant differences between them. You will now explore the important differences
between Tableau and Power BI.
Tableau Power BI
Tableau uses MDX for measures andPower BI uses DAX for calculating measures
dimensions
Tableau is best suitable for experts Power BI is suitable for both experts and
beginners
Power BI is a business analytics tool developed by Microsoft that helps you turn multiple unrelated
data sources into valuable and interactive insights. These data may be in the form of an Excel
spreadsheet or cloud-based/on-premises hybrid data warehouses. You can easily connect to all your
data sources and share the insights with anyone.
Because Power BI provides an easy way for anyone, including non-technical people, to connect,
change, and visualize their raw business data from many different sources and turn it into valuable
data that makes it easy to make smart business decisions.
4. What is Power BI Desktop?
Power Query is a business intelligence tool designed by Microsoft for Excel. Power Query allows
you to import data from various data sources and will enable you to clean, transform and reshape
your data as per the requirements. Power Query allows you to write your query once and then run it
with a simple refresh.
Several data sources can be connected to Power BI, which is grouped into three main types:
● Files
It can import data from Excel (.xlsx, .xlxm), Power BI Desktop files (.pbix) and Comma-Separated
Values (.csv).
● Content Packs
These are a collection of related documents or files stored as a group. There are two types of content
packs in Power BI:
● Content packs from services providers like Google Analytics, Marketo, or Salesforce and
Content packs are created and shared by other users in your organization.
● Connectors
Connectors help you connect your databases and datasets with apps, services, and data in the cloud.
This option offers the most straightforward and simplistic model. It involves setting up on singular
Workspace to be utilized as a “Dev” environment. Here, the report creator (and other collaborating
members) can publish a report to the Workspace and make changes without end users being able to
see. When the development team is finished with their changes, they can push to the corresponding
App, which acts as a “Prod” environment.
The biggest issue with this method is that there isn’t a designated “Test” environment. Technically
the report creator(s) could do a direct report share with Test users during the User Acceptance
Testing(UAT) phase. The downside with this option is that while UAT is going on, no additional
development can happen without the testers immediately seeing the changes. Also, if the report needs
to reference different database connections (Dev, Test, Prod), this option makes it unable to reference
both Dev and Test.
Handling Dev/Test/Production Environments Option 2:
The second option offers a more robust solution with entirely different Workspaces for
Dev/Test/Prod, including corresponding Apps for Test and Prod. A report would be created and
published to a Dev Workspace. Once ready, it would then be re-published to a Test Workspace (with
new database connections, if necessary). The App would be created to allow testers for the UAT
phase. When that phase is complete, the report would finally be re-published to a Prod Workspace. A
Prod App would be created to allow for the end users to view the report.
While this is certainly the more ideal way to handle the report progression, it also involves much
more upkeep. The first method involved managing two elements (1 Workspace, 1 App), but this
method involves managing five elements (3 Workspaces, 2 Apps). Remember that all of this setup is
for one subject matter and/or end users. If you’re in a BI team that creates reports for Finance,
Marketing, HR, etc., this five-element setup needs to be multiplied for each of those groups.
Handling Dev/Test/Production Environments Option 3:
While those are the two main options suggested in the white paper, there is another solution that
could be a happy-medium. This option includes a Development Workspace where the initial report
would be published. When ready for UAT, the report would be re-published in a separate Test
Workspace and testers would be given access to the report. Once vetted, the report would be pushed
to the App, which would serve as a Production environment where end users would be given access.
This option offers a designated place for all three phases, while limiting the amount of upkeep. And if
you want to limit the upkeep even more, you can reuse the Development workspace as a repository
for all reports in development, regardless of the subject matter.
3. You may be prompted to open the Microsoft store application. Click on Open.
4.The Microsoft Store opens and takes you directly to the Power BI Desktop
download page. Click on Install.
That is all you need to do. Power BI Desktop will automatically update, so you can
be sure that you always have the latest version of the software.
3. The next page presents information about Power BI Desktop, its file size, and the system
requirements. Select your language and click on Download:
4. The next step is to select either the 32-bit or 64-bit version of the software. Installing the 64-bit
version will provide maximum performance benefits when analyzing data. Click on Next.
6. When the download has been completed, open the file. This begins with the
Setup Wizard . Select your language and click on Next.
7. Follow the steps of the wizard to confirm the license terms, file path of the software, and complete
the installation by clicking on Finish.
Creating a Power BI account
You do not need a Power BI account to get started learning Power BI Desktop. However, you will
need a Power BI account to publish reports and use the Power BI service.
There are two ways to obtain a Power BI account:
● Sign up for a free, pro, or premium account as an individual. This requires a work or school email
account. E-mail accounts such as outlook.com and gmail.com are not supported.
● You may be assigned a license from an administrator at your organization.
Follow the following steps to sign up for a Power BI account:
1. Navigate to the following URL—powerbi.microsoft.com
2. Click either on the Start free or Try free link .
3. You may be taken to another page, where you need to click on the Try Power BI for free or Try
free link again
4. You will probably be recognized as already using a Microsoft account, at which point you can sign
in
5. If you are not recognized, you will need to enter a valid e-mail address to sign up. You will be
requested to review and accept the terms and conditions. It may take a short while to set up your
account. You should be taken to the Power BI service in a Web browser on completion.
Unit – 2
2 Marks
1. What are Filters in Power BI?
The term "Filter" is self-explanatory. Filters are mathematical and logical conditions applied to data
to filter out essential information in rows and columns. The following are the variety of filters
available in Power BI:
● Manual filters
● Auto filters
● Include/Exclude filters
● Drill-down filters
● Cross Drill filters
● Drillthrough filters
● Drillthrough filters
● URL filters–transient
● Pass-Through filters
Answer : “MMMM” is a user-defined format for date/time that displays the full month name as the
month. FORMAT([Date],”MMMM DD, YYYY”) is the right DAX expression.
There are six different types of join available when performing a merge query. These are
known as Join Kinds and are used to specify how we would like to join the two queries.
The following is an explanation of the six different join types.
1. Left Outer: All rows from the first table and only those that match from the
second. This type of merge is often referred to as a typical lookup that you
may perform in Excel. This is the default and most used type of merge. It is
used to add columns to a table from another table. If no match is found in the
second table, a null value is returned.
2. Right Outer: Returns all rows from the second table regardless of whether
there is a match in the first. The rows where there is no match in the first table
will return null values. This merge is a reverse of the first join kind.
3. Full Outer: The merge will return all rows from both the first and second
tables matching the rows that it can. This ensures that all records from both
tables are returned.
4. Inner: This merge type only returns the matching rows (the records that
appear in both tables). Any rows without a match in the first or second tables
will not be returned.
5. Left Anti: The Anti merge types return the rows that appear in one table and
not the other. For the Left Anti, this means it returns all rows in the first table
that do not have a match in the second table. The columns returned for the
second table will all contain null values due to the nature of this merge.
6. Right Anti: The Right Anti is the reverse of the Left Anti join type. It will
return only the rows that appear in the second table and not the first. The
columns returned for the first table will all contain null values.
Consider the Date of joined column in employee table. This column contains dates in the ISO
format. As there are no delimiters in the date format, the Whole Number data type was automatically
applied by Power Query. the values.
First, we change it to the Text data type. Then we change it to the Date data type as a separate step.
Click the change type button in the Date Joined header and click Text.
1. Click the change type button in the Date Joined header and click Date. A message appears asking if
you would like to change the existing changed type step or add a new changed type step for this
conversion.
2. Click Add new step. It is important that we preserve the previous change to the Text data type.
There are many calculations that you can perform in Power Query while writing little to no M
code (the language of Power Query). examples, including basic mathematical calculations,
date functions, inserting conditional columns, and rounding values. The Power Query UI
provides buttons to perform a variety of calculations on both the Transform and Add Column
tabs.
Figure shows the Transform tab on the Ribbon. The Number Column and Date and Time
Column groups provide easy access to many formulas. Using the formulas on the Transform
tab will change the values in the existing column.
Figure shows the formulas on the Add Column tab of the Ribbon. These formulas would not
change the existing column values but would add a new column with the formula results.
The same formulas are available here, as were seen on the Transform tab. There are additional
formulas at the start of the Ribbon, though, including Custom Column, Conditional Column,
and Index Column.
6. How Rounding values can be performed in power bi.
Click on the DoB column to select it. Click Add Column | Date | Age. Calculate age from date of
birth. A new column named Age is added to the end of the table. It has returned the number of days
difference and a time value.This is not the result that we need, so we will add further transformation
steps.
● Click on the Age column to select it.
● Click Transform | Duration | Total Years
The Age column now shows the total years as a decimal value
To remove the decimal part of the result, we will round down to the nearest integer.
As we are calculating their age, it is important we round down at this step.
● Click on the Age column to select it.
● Click Transform | Rounding | Round Down
Unpivoting columns convert header values into a single column and place all values
that belong to that header in a column alongside them. This is also commonly
referred to as flattening a table.
The header values in green are converted into a single column named Attributes.
The values in blue are placed in a single column named Values and sit beside the
header they belong to.
Unpivot columns option is available in Transform | Unpivot Columns. There are three options under
unpivot columns
1.unpivot columns
2. Unpivot Other Columns
3.unpivot only selected columns
10marks
1. Adding conditional columns
Imagine you have a sales dataset with the following columns:
● ProductID
● SalesAmount
● Region
● SalesDate
You want to create a new column called SalesCategory based on these conditions:
1. If SalesAmount is greater than $1000, label it as "High".
2. If SalesAmount is between $500 and $1000 (inclusive), label it as "Medium".
3. If SalesAmount is less than $500, label it as "Low".
4. If the Region is "North", append " (North)" to the label.
Steps to Add Conditional Columns Using GUI in Power BI
Step 1: Load Your Data
1. Open Power BI Desktop.
2. Load your dataset by clicking on "Get Data" and selecting your data source (e.g., Excel,
CSV).
Step 2: Open Power Query Editor
1. Once your data is loaded, click on the "Transform Data" button in the Home tab to open the
Power Query Editor.
Step 3: Add a Conditional Column
1. In the Power Query Editor, navigate to the Add Column tab in the ribbon.
2. Click on Conditional Column.
Step 4: Configure the Conditional Column
1. Name your new column: In the dialog box that appears, enter SalesCategory as the name of
the new column.
2. Set up your conditions:
○ First Condition:
■ In the "Column Name" dropdown, select SalesAmount.
■ Choose "is greater than" in the "Operator" dropdown.
■ Enter 1000 in the "Value" box.
■ In the "Output" box, enter High.
○ Add another condition:
■ Click on "Add Clause".
■ In the new row, select SalesAmount, choose "is greater than or equal to", and
enter 500.
■ In the "Output" box, enter Medium.
○ Add another condition:
■ Click on "Add Clause" again.
■ Select SalesAmount, choose "is less than", and enter 500.
■ In the "Output" box, enter Low.
○ Ensure that the conditions are set to be evaluated in the order they are listed.
3. Click OK to create the initial SalesCategory column.
Step 5: Modify the Column for Region
Now, you need to modify the column to append " (North)" for entries from the North region.
1. With the newly created SalesCategory column selected, go to the Add Column tab again.
2. Click on Custom Column.
3. In the Custom Column dialog:
○ Name your new column SalesCategoryFinal (or you can overwrite the previous one).
○ In the formula box, enter the following formula:
if [Region] = "North" then [SalesCategory] & " (North)" else [SalesCategory]
4.
5. Click OK to create this column.
Step 6: Close and Apply
1. Once you’ve created the conditional columns, click on Close & Apply in the Power Query
Editor.
2. The new SalesCategoryFinal column will now be available in your data model
View Tab
3. Column quality:
we can easily see valid, Error and Empty percentage of data values associated with the Selected
table.
Column Quality
You can perform various transformations like Remove Errors, Remove Empty, Replace Errors, keep
duplicates, Remove Duplicates, etc. by clicking on the eclipses (…) or right-clicking on the visual.
Right, Click on the visual.
4. Column distribution:
In this section, we can easily see the inline value distribution histogram.
For example, distinct records, unique records.
column distribution
5. Column profile:
This is one of the most important features. As you can see for the selected column.
Column statistics which includes distribution measures like Count, error, empty, distinct, Unique,
Empty string, Min, Max.
The column profile shows the Column statistics and column distribution for the selected column.
Column Profile
Replace one value with another in the selected columns.
Replace Values
2018 https://www.pro-football-reference.com/years/2018/games.html
2017 https://www.pro-football-reference.com/years/2017/games.html
On each page, we are interested in the data available in the “Week-by-Week Games” table.
Here are the steps to retrieve, transform, and analyze the data for the past 10 seasons. We will create
the transformation steps for one season then convert that script into a function that can be repeated
over any number of pages (years) of data on the website.
Open Power BI desktop and click “Transform Data” in the Home Ribbon. This opens Power Query
Editor, where we will define our data transformation. Create a parameter, pYear, to store the
year/season from which we wish to retrieve data. Click on “Manage Parameters” and click “New.”
We will store this as a text type since we will be plugging this into a URL.
Now, click “New Source,” and select “Web” and “Advanced” as shown below. We are breaking the
URL into 3 pieces, a first part (text), the year (parameter pYear), and the page name (text).
Click OK to preview the data and check the “Week-by-Week Games Table” to preview the data.
Click OK to import the data. At this point, we will need to do some data transformations before we
can analyze it. One of the first transformations to perform is to promote the first row as headers. Click
on “Use First Row as Headers” in the Home ribbon of Power Query Editor.
The first column, “Week” stores the season week number and playoffs round (e.g., WildCard,
Division, ConfChamp). It also has the repeating header, “Week” and there are some blank values. To
remove the blanks, click the arrow in the header, and select “Remove Empty.” Similarly, uncheck the
box next to “Week” and click OK.
One of the columns holds links to the boxscore for each game. This is not necessary for our dataset,
so let’s remove it by right-clicking on the column header and selecting “Remove.”
The table stores the winning team and the losing team in dedicated columns, with a column
containing the “@” symbol to denote if the game was played in the losing team’s stadium. This
column does not have a name, so rename it to “Location” (double-click the header and type
“Location”).
There is some other interesting information we can get from this dataset, like how often the home
team loses. To do this, click “Add Column” and “Conditional Column.” We will name this
“HomeTeamOutcome,” and the logic will be that if the “Location” column equals “@” then the home
team lost. See below.
Another useful column to have is an index column with a unique value for each row. This way, the
model can contain measures that count the number of distinct values of an ID field, as an example.
We will call this “GameID” and create it by clicking “Index Column” in the “Add Column Ribbon.”
We want our first value to be 1, not zero, so we select “From 1” in the drop-down. To rename the
resulting column named “Index,” double-click the column header and type “GameID.”
There is a lot more we could do to model this data, but for the purposes of the demonstration, we will
go ahead and convert this to a function and retrieve data for the last 10 seasons. We should rename
the table to “Season” by editing the Name in the Query Settings box.
Create the fnGetSeason Data Retrieval Function
To convert this into a function, right-click on the Season query in the Queries pane and select “Create
Function.”
Power BI detects that a parameter (pYear) is used in the function, and we can name the function
“fnGetSeason.”
Click OK and the function is created. Since we do not want the “Season” query to load in the report,
right-click and uncheck “Enable Load” in the dialog box.
We will need values to input into the function, so we will create a table with 10 rows, one for each of
the last 10 seasons. On the Home ribbon, click “Enter Data” and populate it as follows. Double click
on the column header to name the column “Year” and name the table “SeasonData.” Click OK and
there is now a table from which we will use our fnGetSeason function.
So we don’t have to do a text conversion inside the function, go ahead and change the type of column
for “Year” in SeasonData to Text. Right-click the column header, select “Change Type” and select
“Text.”
Load the Data
Now the fun part, calling the function and watching the data load!
While in the SeasonData table, activate the “Add Column” tab and select “Invoke Custom Function.”
For the pYear value, make sure “Column Name” is selected, and choose “Year” in the field
dropdown. Click OK and a new column will be created. This will be a table column, containing a
table in each cell.
By clicking the expand contents button in the column header , we can expand all of the contents, with
the Year column propagating next to the information about each game. Uncheck the “Use original
column name as prefix” option and click OK.
A preview of data will be displayed in the SeasonData table. You may notice that the field types are
of the “Any” category. We need to model those explicitly for the best results. The points (PtsW =
winning team points, PtsL = losing team points), number of yards (YdsW, YdsL), turnovers (TOW,
TOL), and GameID fields should be changed to Whole Number, with the remaining fields stored as
Text.
Load the data into the model by clicking “Close and Apply” from the Home Ribbon. This will load
data from the last 10 seasons into the SeasonData table. It is probably a good idea to save the
workbook at this point. Click the save button and save the file as “NFL Seasons.pbix.”
Create Columns and Measures
We might want to distinguish regular-season games from playoffs. To do this, remember we have a
field called “Week” with week number of the regular season and the round of playoffs. Since the
week number of the regular season is at most 2 digits and the playoffs are longer text values
(SuperBowl, WildCard, etc.), we can use the LEN function inside an IF statement to classify the
game as Regular Season or Playoffs. Right-click on the SeasonData table and select “New Column.”
In the formula editor, type the following:
GameType = if(len(SeasonData[Week]) < 3, "Regular Season", "Playoffs")
It is a good practice to create explicit measures in Power BI that define the calculations we want to
perform, rather than relying on aggregations of the columns as they are dropped into visuals. A
simple measure is the count of the number of games, accomplished by counting the number of
distinct GameID values. Right-click on SeasonData and select “New Measure.” Populate the formula
bar with the following text:
Games = DISTINCTCOUNT(SeasonData[GameID])
With this measure, we can create several visualizations, including counting the number of games
where the home team wins/loses by year and game type (see below for a graph showing the home
team wins and losses by year in the regular season since 2010). 2019 saw the lowest home team
winning percentage in the last 10 years.
Another example can be created showing the average score in the regular season. Create the
following two measures:
Avg Points Lose = AVERAGE(SeasonData[PtsL])
Avg Points Win = AVERAGE(SeasonData[PtsW])
Then, create a clustered column chart and filter the data where GameType = “Regular Season” as
shown below.
Unit 3
2 Marks
1. What are the two types of RLS in Power BI?
The two types of RLS in Power BI are Static RLS and Dynamic RLS. Static RLS is the
simpler of the two and requires a Power BI developer to manually define security-based logic.
Data Modeling refers to the process of creating a visual representation of an entire information
system or some of its parts to communicate the relationships between data points and structures. The
purpose is to show the types of data stored in the system, the relationships among the data types, the
formats and attributes of the data, and how the data can be grouped and organized.
Data Models are normally created around business needs. Requirements and rules are defined upfront
via feedback obtained from business stakeholders so that they can be used for designing a new
system. The Data Modeling process begins with the collection of information about business
requirements from both stakeholders and end-users. The business requirements are then translated
into data structures for the formulation of a concrete Database design.
Data Visualization refers to the process of representing data and information graphically. By the use
of visual elements like graphs, charts, and maps, Data Visualization tools offer an accessible way to
view and understand trends and patterns in data.
Data Visualization helps organizations to analyze huge volumes of data and make data-driven
decisions. It also makes it easy for individuals and companies to understand data. Data Visualization
is very useful today as companies are generating and collecting huge data volumes. It can help them
to unmask hidden gems from data, which are good for growth.
2. In the Data pane, expand Time and drag FiscalMonth to the X-axis area of
the Visualizations pane. You can now see comparisons by month:
3. In this step, you change the visualization type. There are many visualization types to choose
from. To decide which type to use, see descriptions of each, tips for best practices, and tutorials.
To use an area chart, in the Visualizations pane, select the Area chart button:
4. Sort the visualization by selecting More options (...) at the top of the chart and then
selecting Sort axis > FiscalMonth:
5. Resize the visualization by selecting it and dragging one of the frame handles. Make it wide
enough to eliminate the scrollbar but small enough to leave room for another visualization: