Oracle
Oracle
What is DAX?
Ans: To do basic calculation and data analysis on data in power pivot, we use Data Analysis
Expression (DAX). It is formula language used to compute calculated column and calculated field.
DAX works on column values.
DAX can not modify or insert data.
We can create calculated column and measures with DAX but we can not calculate rows
using DAX.
Sample DAX formula syntax:
For the measure named Total Sales, calculate (=) the SUM of values in the [SalesAmount] column in
the Sales table.
A- Measure Name
B- = – indicate beginning of formula
C- DAX Function
D- Parenthesis for Sum Function
E- Referenced Table
F- Referenced column name
Ans: Below are some of the most commonly used DAX function:
SUM, MIN, MAX, AVG, COUNTROWS, DISTINCTCOUNT
IF, AND, OR, SWITCH
ISBLANK, ISFILTERED, ISCROSSFILTERED
VALUES, ALL, FILTER, CALCULATE,
UNION, INTERSECT, EXCEPT, NATURALINNERJOIN,
NATURALLEFTEROUTERJOIN,
SUMMARIZECOLUMNS, ISEMPTY,
VAR (Variables)
GEOMEAN, MEDIAN, DATEDIFF
Home Import data from Query Editor into the New Query group
Use the Parameter group to create and manage parameters
Include a function to refresh the preview data for the
current table, or all tables, in the dataset
Manage columns, reduce rows, and sort groups
Add Column Use Add Custom Column to create a new column using a
DAX formula
Use Conditional Column to add a column based on the values
in another column
Use
the From Number group to apply statistical, standard, and
scientific functions to numerical columns
What is the difference between Calculated Columns, Calculated Tables, and Measures?
Calculated Columns Calculated Tables Measures
Is it possible to refresh Power BI Reports after they are published to the cloud?
Yes, it is possible. Gateways can be used to do so.
For SharePoint: Data Management Gateway
For Powerbi.com: Power BI Personal Gateway
What happens when you click on a single data point in one of the multiple visuals in a report?
When we do that, data gets selected and copied to the clipboard. Further, the copied data can be
pasted anywhere as per the requirement of the user.
What is z-order in Power BI?
Z-order is a design strategy that is used for arranging visuals over shapes. Also, z-order can be defined
as an implementation method that can be applied when reports have multiple elements. Further, this
can also be used to refresh the display after the order of items in a report is changed.
2. Datasets: Dataset is a collection of data that Power BI uses to create its visualizations.
Example: Excel sheets, Oracle or SQL server tables.
3. 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 by
Products report etc.
Organizational content packs provide users, BI professionals, and system integrator the tools to build
their own content packs to share purpose-built dashboards, reports, and datasets within their
organization.
Power BI Interview Questions – DAX
Ans: The FILTER function returns a table with a filter condition applied for each of its source table
rows. The FILTER function is rarely used in isolation, it’s generally used as a parameter to other
functions such as CALCULATE.
FILTER is an iterator and thus can negatively impact performance over large source tables.
Complex filtering logic can be applied such as referencing a measure in a filter expression.
o FILTER(MyTable,[SalesMetric] > 500)
Ans: These are the only functions that allow you modify filter context of measures or tables.
Add to existing filter context of queries.
Override filter context from queries.
Remove existing filter context from queries.
Limitations:
Filter parameters can only operate on a single column at a time.
Filter parameters cannot reference a metric.
Ans: SUMMARIZE()
Main groupby function in SSAS.
Recommended practice is to specify table and group by columns but not metrics.You can use
ADDCOLUMNS function.
SUMMARIZECOLUMNS
New group by function for SSAS and Power BI Desktop; more efficient.
Specify group by columns, table, and expressions.
How would you create trailing X month metrics via DAX against a non-standard calendar?
What are some of differences in data modeling between Power BI Desktop and Power Pivot for
Excel?
Ans: Here are some of the differences:
Power BI Desktop supports bi-directional cross filtering relationships, security, calculated
tables, and Direct Query options.
Power Pivot for Excel has single direction (one to many) relationships, calculated columns
only, and supports import mode only. Security roles cannot be defined in Power Pivot for
Excel.
Can we have more than one active relationship between two tables in data model of power
pivot?
Ans: No, we cannot have more than one active relationship between two tables. However, can have
more than one relationship between two tables but there will be only one active relationship and many
inactive relationship. The dotted lines are inactive and continuous line are active.
Power BI Interview Questions – Power Query
Why do we need Power Query when Power Pivot can import data from mostly used sources?
Ans: Power Query is a self-service ETL (Extract, Transform, Load) tool which runs as an Excel add-
in. It allows users to pull data from various sources, manipulate said data into a form that suits their
needs and load it into Excel. It is most optimum to use Power Query over Power Pivot as it lets you
not only load the data but also manipulate it as per the users needs while loading.
Power BI Interview Questions – Power Map
What are the primary requirement for a table to be used in Power Map?
Ans: For a data to be consumed in power map there should be location data like:
Latitude/Longitude pair
Street, City, Country/Region, Zip Code/Postal Code, and State/Province, which can be
geolocated by Bing
The primary requirement for the table is that it contains unique rows. It must also contain location
data, which can be in the form of a Latitude/Longitude pair, although this is not a requirement. You
can use address fields instead, such as Street, City, Country/Region, Zip Code/Postal Code, and
State/Province, which can be geolocated by Bing.
Can we refresh our Power BI reports once uploaded to cloud (Share point or Powebi.com)?
Ans: Yes we can refresh our reports through Data Management gateway(for sharepoint), and Power
BI Personal gateway(for Powerbi.com)
What are the different types of refreshing data for our published reports?
Ans: There are four main types of refresh in Power BI. Package refresh, model or data refresh, tile
refresh and visual container refresh.
Package refresh
This synchronizes your Power BI Desktop, or Excel, file between the Power BI service and OneDrive,
or SharePoint Online. However, this does not pull data from the original data source. The dataset in
Power BI will only be updated with what is in the file within OneDrive, or SharePoint Online.
Model/data refresh
It referrs to refreshing the dataset, within the Power BI service, with data from the original data
source. This is done by either using scheduled refresh, or refresh now. This requires a gateway for on-
premises data sources.
Tile refresh
Tile refresh updates the cache for tile visuals, on the dashboard, once data changes. This happens
about every fifteen minutes. You can also force a tile refresh by selecting the ellipsis (…) in the upper
right of a dashboard and selecting Refresh dashboard tiles.
Visual container refresh
Refreshing the visual container updates the cached report visuals, within a report, once the data
changes.
To know more about data refresh and understand how to implement data refresh, you can check the
following link.
What is a calculated column in Power BI and why would you use them?
Ans: Calculated Columns are DAX expressions that are computed during the model’s
processing/refresh process for each row of the given column and can be used like any other column in
the model.
Calculated columns are not compressed and thus consume more memory and result in reduced query
performance. They can also reduce processing/refresh performance if applied on large fact tables and
can make a model more difficult to maintain/support given
that the calculated column is not present in the source system.
What are many-to-many relationships and how can they be addressed in Power BI ?
Ans: Many to Many relationships involve a bridge or junction table reflecting the combinations of
two dimensions (e.g. doctors and patients). Either all possible combinations or those combinations
that have occurred.
Bi-Directional Crossfiltering relationships can be used in PBIX.
CROSSFILTER function can be used in Power Pivot for Excel.
DAX can be used per metric to check and optionally modify the filter context.
Why might you have a table in the model without any relationships to other tables?
Ans: There are mainly 2 reasons why we would have tables without relations in our model:
A disconnected table might be used to present the user with parameter values to be exposed
and selected in slicers (e.g. growth assumption.)
o DAX metrics could retrieve this selection and use it with other calculations/metrics.
A disconnected table may also be used as a placeholder for metrics in the user interface.
o It may not contain any rows of data and its columns could be hidden but all metrics
are visible.
Ans: You can use Power BI publisher for Excel to pin ranges, pivot tables and charts to Power BI.
The user can manage the tiles – refresh them, remove them, in Excel.
Pinned items must be removed from the dashboard in the service (removing in Excel only
deletes the connection).
The Power BI Publisher for Excel can also be used to connect from Excel to datasets that are
hosted in the Power BI Service.
An Excel pivot table is generated with a connection (ODC file) to the data in Azure.
The Publisher installs all necessary drivers on local machine to establish connectivity .
What are the differences between a Power BI Dataset, a Report, and a Dashboard?
Ans: Dataset: The source used to create reports and visuals/tiles.
A data model (local to PBIX or XLSX) or model in an Analysis Services Server
Data could be inside of model (imported) or a Direct Query connection to a source.
Report: An individual Power BI Desktop file (PBIX) containing one or more report pages.
Built for deep, interactive analysis experience for a given dataset (filters, formatting).
Each Report is connected to atleast one dataset
Each page containing one or more visuals or tiles.
Dashboard: a collection of visuals or tiles from different reports and, optionally, a pinned.
Built to aggregate primary visuals and metrics from multiple datasets.
What are the three Edit Interactions options of a visual tile in Power BI Desktop?
Ans: The 3 edit interaction options are Filter, Highlight, and None.
Filter: It completely filter a visual/tile based on the filter selection of another visual/tile.
Highlight: It highlight only the related elements on the visual/tile, gray out the non-related items.
None: It ignore the filter selection from another tile/visual.
What are some of the differences in report authoring capabilities between using a live or direct
query connection such as to an Analysis Services model, relative to working with a data model
local to the Power BI Desktop file?
Ans: With a data model local to the PBIX file (or Power Pivot workbook), the author has full control
over the queries, the modeling/relationships, the metadata and the metrics.
With a live connection to an Analysis Services database (cube) the user cannot create new metrics,
import new data, change the formatting of the metrics, etc – the user can only use the visualization,
analytics, and formatting available on the report canvas.
With a direct query model in Power BI to SQL Server, for example, the author has access to the same
features (and limitations) available to SSAS Direct Query mode.
Only one data source (one database on one server) may be used, certain DAX functions are
not optimized, and the user cannot use Query Editor functions that cannot be translated into
SQL statements.
1) Simple Loop
A Simple Loop is used when a set of statements is to be executed at least once before the loop terminates.
An EXIT condition must be specified in the loop, otherwise the loop will get into an infinite number of
iterations. When the EXIT condition is satisfied the process exits from the loop.
General Syntax to write a Simple Loop is
:
LOOP
statements;
EXIT;
{or EXIT WHEN condition;}
END LOOP;
These are the important steps to be followed while using Simple Loop.
1) The counter variable is implicitly declared in the declaration section, so it's not necessary to declare
it explicity.
2) The counter variable is incremented by 1 and does not need to be incremented explicitly.
3) EXIT WHEN statement and EXIT statements can be used in FOR loops but it's not done oftenly.
NOTE: The above Loops are explained with a example when dealing with Explicit Cursors.
Implicit Cursors: Application
When you execute DML statements like DELETE, INSERT, UPDATE and SELECT statements,
implicit statements are created to process these statements.
Oracle provides few attributes called as implicit cursor attributes to check the status of DML
operations. The cursor attributes available are %FOUND, %NOTFOUND, %ROWCOUNT, and
%ISOPEN.
For example, When you execute INSERT, UPDATE, or DELETE statements the cursor attributes tell
us whether any rows are affected and how many have been affected.
When a SELECT... INTO statement is executed in a PL/SQL Block, implicit cursor attributes can be
used to find out whether any row has been returned by the SELECT statement. PL/SQL returns an
error when no data is selected.
The status of the cursor for each of these attributes are defined in the below table.
Attributes Return Value Example
%FOUND The return value is TRUE, if the DML statements SQL%FOUND
like INSERT, DELETE and UPDATE affect at least
one row and if SELECT ….INTO statement return
at least one row.
The return value is FALSE, if DML statements like
INSERT, DELETE and UPDATE do not affect row
and if SELECT….INTO statement do not return a
row.
%NOTFOUND The return value is FALSE, if DML statements like SQL%NOTFOUND
INSERT, DELETE and UPDATE at least one row
and if SELECT ….INTO statement return at least
one row.
The return value is TRUE, if a DML statement like
INSERT, DELETE and UPDATE do not affect even
one row and if SELECT ….INTO statement does
not return a row.
%ROWCOUNT Return the number of rows affected by the DML SQL%ROWCOUNT
operations INSERT, DELETE, UPDATE, SELECT
For Example: Consider the PL/SQL Block that uses implicit cursor attributes as shown below:
DECLARE var_rows number(5);
BEGIN
UPDATE employee
SET salary = salary + 1000;
IF SQL%NOTFOUND THEN
dbms_output.put_line('None of the salaries where updated');
ELSIF SQL%FOUND THEN
var_rows := SQL%ROWCOUNT;
dbms_output.put_line('Salaries for ' || var_rows || 'employees are updated');
END IF;
END;
In the above PL/SQL Block, the salaries of all the employees in the ‘employee’ table are updated. If
none of the employee’s salary are updated we get a message 'None of the salaries where updated'. Else
we get a message like for example, 'Salaries for 1000 employees are updated' if there are 1000 rows in
‘employee’ table.
Explicit Cursors
An explicit cursor is defined in the declaration section of the PL/SQL Block. It is created on a SELECT
Statement which returns more than one row. We can provide a suitable name for the cursor.
General Syntax for creating a cursor is as given below:
CURSOR cursor_name IS select_statement;
Example 1:
1> DECLARE
2> emp_rec emp_tbl%rowtype;
3> CURSOR emp_cur IS
4> SELECT *
5> FROM
6> WHERE salary > 10;
7> BEGIN
8> OPEN emp_cur;
9> FETCH emp_cur INTO emp_rec;
10> dbms_output.put_line (emp_rec.first_name || ' ' || emp_rec.last_name);
11> CLOSE emp_cur;
12> END;
In the above example, first we are creating a record ‘emp_rec’ of the same structure as of table
‘emp_tbl’ in line no 2. We can also create a record with a cursor by replacing the table name with the
cursor name. Second, we are declaring a cursor ‘emp_cur’ from a select query in line no 3 - 6. Third,
we are opening the cursor in the execution section in line no 8. Fourth, we are fetching the cursor to
the record in line no 9. Fifth, we are displaying the first_name and last_name of the employee in the
record emp_rec in line no 10. Sixth, we are closing the cursor in line no 11.
What are Explicit Cursor Attributes?
Oracle provides some attributes known as Explicit Cursor Attributes to control the data processing
while using cursors. We use these attributes to avoid errors while accessing cursors through OPEN,
FETCH and CLOSE Statements.
When does an error occur while accessing an explicit cursor?
a) When we try to open a cursor which is not closed in the previous operation.
b) When we try to fetch a cursor after the last operation.
These are the attributes available to check the status of an explicit cursor.
Attributes Return values Example
%FOUND TRUE, if fetch statement returns at least Cursor_name%FOUND
one row.
FALSE, if fetch statement doesn’t return a
row.
%NOTFOUND TRUE, , if fetch statement doesn’t return a Cursor_name%NOTFOUND
row.
FALSE, if fetch statement returns at least
one row.
%ROWCOUNT The number of rows fetched by the fetch Cursor_name%ROWCOUNT
statement
If no row is returned, the PL/SQL
statement returns an error.
%ISOPEN TRUE, if the cursor is already open in the Cursor_name%ISNAME
program
FALSE, if the cursor is not opened in the
program.
1) IN parameter:
This is similar to passing parameters in programming languages. We can pass values to the stored procedure
through these parameters or variables. This type of parameter is a read only parameter. We can assign the
value of IN type parameter to a variable or use it in a query, but we cannot change its value inside the
procedure.
General syntax to pass a IN parameter is
CREATE [OR REPLACE] PROCEDURE procedure_name (
param_name1 IN datatype, param_name12 IN datatype ... )
param_name1, •param_name2... are unique parameter names.
datatype - defines the datatype of the variable.
IN - is optional, by default it is a IN type parameter.
2) OUT Parameter:
The OUT parameters are used to send the OUTPUT from a procedure or a function. This is a write-
only parameter i.e, we cannot pass values to OUT paramters while executing the stored procedure, but
we can assign values to OUT parameter inside the stored procedure and the calling program can
recieve this output value.
The General syntax to create an OUT parameter is
CREATE [OR REPLACE] PROCEDURE proc2 (param_name OUT datatype)
The parameter should be explicity declared as OUT parameter.
3) IN OUT Parameter:
The IN OUT parameter allows us to pass values into a procedure and get output values from the
procedure. This parameter is used if the value of the IN parameter can be changed in the calling
program.
By using IN OUT parameter we can pass values into a parameter and return a value to the calling
program using the same parameter. But this is possible only if the value passed to the procedure and
output value have a same datatype. This parameter is used if the value of the parameter will be
changed in the procedure.
The General syntax to create an IN OUT parameter is
CREATE [OR REPLACE] PROCEDURE proc3 (param_name IN OUT datatype)