SQL Server Interview Questions (BASIC)

1. What is denormalization and when would you go for it?

As the name indicates, denormalization is the reverse process of normalization. It's the
controlled introduction of redundancy in to the database design. It helps improve the query
performance as the number of joins could be reduced.

2. How do you implement one-to-one, one-to-many and many-to-many relationships
while designing tables?
One-to-One relationship can be implemented as a single table and rarely as two tables with
primary and foreign key relationships. One-to-Many relationships are implemented by splitting
the data into two tables with primary key and foreign key relationships. Many-to-Many
relationships are implemented using a junction table with the keys from both the tables
forming the composite primary key of the junction table.

3. What's the difference between a primary key and a unique key?
Both primary key and unique enforce uniqueness of the column on which they are defined. But
by default primary key creates a clustered index on the column, where are unique creates a
nonclustered index by default. Another major difference is that, primary key doesn't allow
NULLs, but unique key allows one NULL only.

4. What are user defined datatypes and when you should go for them?
User defined datatypes let you extend the base SQL Server datatypes by providing a
descriptive name, and format to the database. Take for example, in your database, there is a
column called ZIP_Code which appears in many tables. In all these tables it should be
varchar(6). In this case you could create a user defined datatype called ZIP_Code_Type of
varchar(6) and use it across all your tables.

5. What is bit datatype and what's the information that can be stored inside a bit
column?
Bit datatype is used to store boolean information like 1 or 0 (true or false). Untill SQL Server
6.5 bit datatype could hold either a 1 or 0 and there was no support for NULL. But from SQL
Server 7.0 onwards, bit datatype can represent a third state, which is NULL.

6. Define candidate key, alternate key, composite key.
A candidate key is one that can identify each row of a table uniquely. Generally a candidate
key becomes the primary key of the table. If the table has more than one candidate key, one
of them will become the primary key, and the rest are called alternate keys. A key formed by
combining at least two or more columns is called composite key.

7. What are defaults? Is there a column to which a default can't be bound?
A default is a value that will be used by a column, if no value is supplied to that column while
inserting data. IDENTITY columns and timestamp columns can't have defaults bound to them.
See CREATE DEFUALT in books online.

8. What is a transaction and what are ACID properties?
A transaction is a logical unit of work in which, all the steps must be performed or none. ACID
stands for Atomicity, Consistency, Isolation, Durability. These are the properties of a
transaction. For more information and explanation of these properties, see SQL Server books
online or any RDBMS fundamentals text book.

9. Explain different isolation levels An isolation level determines the degree of isolation
of data between concurrent transactions.
The default SQL Server isolation level is Read Committed. Here are the other isolation levels
(in the ascending order of isolation): Read Uncommitted, Read Committed, Repeatable Read,
Serializable.

10. How does .NET and SQL SERVER thread is work?
There are two types of threading pre-emptive and Non-preemptive but Sql Server support
Non-preemptive and .NET thread model is different. Because Sql have to handle thread in
different way for SQLCLR this different thread are known as Tasking of Threads . In this thread
there is a switch between SQLCLR and SQL SERVER threads .SQL SERVER uses blocking points
for transition to happen between SQLCLR and SQL SERVER threads.

11. What's the maximum size of a row?
8060 bytes.

12. What is lock escalation?
Strong names are required to store shared assemblies in the global assembly cache (GAC).
This is because the GAC allows multiple versions of the same assembly to reside on your
system simultaneously, so that each application can find and use its own version of your
assembly. This helps avoid DLL Hell, where applications that may be compiled to different
versions of your assembly could potentially break because they are all forced to use the same
version of your assembly. Another reason to use strong names is to make it difficult for
hackers to spoof your assembly, in other words, replace or inject your assembly with a virus
or malicious code.

13. What's the difference between DELETE TABLE and TRUNCATE TABLE commands?
DELETE TABLE is a logged operation, so the deletion of each row gets logged in the
transaction log, which makes it slow. TRUNCATE TABLE also deletes all the rows in a table, but
it won't log the deletion of each row, instead it logs the deallocation of the data pages of the
table, which makes it faster. Of course, TRUNCATE TABLE can be rolled back.

14. What are constraints? Explain different types of constraints.
Constraints enable the RDBMS enforce the integrity of the database automatically, without
needing you to create triggers, rule or defaults. Types of constraints: NOT NULL, CHECK,
UNIQUE, PRIMARY KEY, FOREIGN KEY

15. What is an index?
Indexes in SQL Server are similar to the indexes in books. They help SQL Server retrieve the
data quicker.

16. What are the types of indexes?
Indexes are of two types. Clustered indexes and non-clustered indexes. When you craete a
clustered index on a table, all the rows in the table are stored in the order of the clustered
index key. So, there can be only one clustered index per table. Non-clustered indexes have
their own storage separate from the table data storage. Non-clustered indexes are stored as
B-tree structures (so do clustered indexes), with the leaf level nodes having the index key and
it's row locater. The row located could be the RID or the Clustered index key, depending up on
the absence or presence of clustered index on the table.

17. I create a separate index on each column of a table. what are the advantages and
disadvantages of this approach?
If you create an index on each column of a table, it improves the query performance, as the
query optimizer can choose from all the existing indexes to come up with an efficient
execution plan. At the same t ime, data modification operations (such as INSERT, UPDATE,
DELETE) will become slow, as every time data changes in the table, all the indexes need to be
updated. Another disadvantage is that, indexes need disk space, the more indexes you have,
more disk space is used.

18. What is RAID and what are different types of RAID configurations?
RAID stands for Redundant Array of Inexpensive Disks, used to provide fault tolerance to
database servers. There are six RAID levels 0 through 5 offering different levels of
performance, fault tolerance.

19. What are the steps you will take, if you are tasked with securing an SQL Server?
Preferring NT authentication, using server, databse and application roles to control access to
the data, securing the physical database files using NTFS permissions, using an unguessable
SA password, restricting physical access to the SQL Server, renaming the Administrator
account on the SQL Server computer, disabling the Guest account, enabling auditing, using
multiprotocol encryption, setting up SSL, setting up firewalls, isolating SQL Server from the
web server etc.

20. What is a deadlock and what is a live lock? How will you go about resolving
deadlocks?
Deadlock is a situation when two processes, each having a lock on one piece of data, attempt
to acquire a lock on the other's piece. Each process would wait indefinitely for the other to
release the lock, unless one of the user processes is terminated. SQL Server detects deadlocks
and terminates one user's process. A livelock is one, where a request for an exclusive lock is
repeatedly denied because a series of overlapping shared locks keeps interfering. SQL Server
detects the situation after four denials and refuses further shared locks. A livelock also occurs
when read transactions monopolize a table or page, forcing a write transaction to wait
indefinitely.

21. What is blocking and how would you troubleshoot it?
Blocking happens when one connection from an application holds a lock and a second
connection requires a conflicting lock type. This forces the second connection to wait, blocked
on the first.

22. How to restart SQL Server in single user mode?
SQL Server can be started from command line, using the SQLSERVR.EXE. This EXE has some
very important parameters with which a DBA should be familiar with. -m is used for starting
SQL Server in single user mode and -f is used to start the SQL Server in minimal
confuguration mode.

23. what are the DBCC commands that you commonly use for database maintenance?
DBCC CHECKDB - Ensures that tables in the db and the indexes are correctly linked.and DBCC
CHECKALLOC - To check that all pages in a db are correctly allocated. DBCC SQLPERF - It
gives report on current usage of transaction log in percentage. DBCC CHECKFILEGROUP -
Checks all tables file group for any damage.

24. What are statistics?
Statistics determine the selectivity of the indexes. If an indexed column has unique values
then the selectivity of that index is more, as opposed to an index with non-unique values.
Query optimizer uses these indexes in determining whether to choose an index or not while
executing a query.

25. Under what circumstances they go out of date, how do you update statistics?
Some situations under which you should update statistics:
1) If there is significant change in the key values in the index
2) If a large amount of data in an indexed column has been added, changed, or removed (that
is, if the distribution of key values has changed), or the table has been truncated using the
TRUNCATE TABLE statement and then repopulated
3) Database is upgraded from a previous version Look up SQL Server books online for the
following commands: UPDATE STATISTICS, STATS_DATE, DBCC SHOW_STATISTICS, CREATE
STATISTICS, DROP STATISTICS, sp_autostats, sp_createstats, sp_updatestats

26. What are the different ways of moving data/databases between servers and
databases in SQL Server?
BACKUP/RESTORE, dettaching and attaching databases, replication, DTS, BCP, logshipping,
INSERT...SELECT, SELECT...INTO, creating INSERT scripts to generate data.

27. Explian different types of BACKUPs avaialabe in SQL Server?
Full database backup, differential database backup, transaction log backup, filegroup backup.

28. What is database replicaion?
Replication is the process of copying/moving data between databases on the same or different
servers.

29. What are the different types of replication you can set up in SQL Server?
SQL Server supports the following types of replication scenarios:
* Snapshot replication
* Transactional replication (with immediate updating subscribers, with queued updating
subscribers)
* Merge replication

30. How to determine the service pack currently installed on SQL Server?
The global variable @@Version stores the build number of the sqlservr.exe, which is used to
determine the service pack installed.

31. What are cursors?
Cursors allow row-by-row prcessing of the resultsets.

32. Explain different types of cursors.
Types of cursors:
Static, Dynamic, Forward-only, Keyset-driven.

33. What are the disadvantages of cursors?
Disadvantages of cursors:
Each time you fetch a row from the cursor, it results in a network roundtrip, where as a
normal SELECT query makes only one rowundtrip, however large the resultset is. Cursors are
also costly because they require more resources and temporary storage (results in more IO
operations). Furthere, there are restrictions on the SELECT statements that can be used with
some types of cursors.

34. How can you avoid cursors?
Most of the times, set based operations can be used instead of cursors. Another situation in
which developers tend to use cursors: You need to call a stored procedure when a column in a
particular row meets certain condition. You don't have to use cursors for this. This can be
achieved using WHILE loop, as long as there is a unique key to identify each row.

35. What is a join?
Joins are used in queries to explain how different tables are related. Joins also let you select
data from a table depending upon data from another table.

36. Explain different types of joins.
Types of joins:
INNER JOINs, OUTER JOINs, CROSS JOINs. OUTER JOINs are further classified as LEFT OUTER
JOINS, RIGHT OUTER JOINS and FULL OUTER JOINS.

37. Can you have a nested transaction?
Yes, very much.

38. What is an extended stored procedure?
An extended stored procedure is a function within a DLL (written in a programming language
like C, C++ using Open Data Services (ODS) API) that can be called from T-SQL, just the way
we call normal stored procedures using the EXEC statement.

39. Can you instantiate a COM object by using T-SQL?
Yes, you can instantiate a COM (written in languages like VB, VC++) object from T-SQL by
using sp_OACreate stored procedure.

40. What is the system function to get the current user's user id?
USER_ID(). Some more system functions: USER_NAME(), SYSTEM_USER, SESSION_USER,
CURRENT_USER, USER, SUSER_SID(), HOST_NAME().
41. What are triggers?
Triggers are special kind of stored procedures that get executed automatically when an
INSERT, UPDATE or DELETE operation takes place on a table.
42. How many triggers you can have on a table?
In SQL Server 6.5 you could define only 3 triggers per table, one for INSERT, one for UPDATE
and one for DELETE. From SQL Server 7.0 onwards, this restriction is gone, and you could
create multiple triggers per each action.
43. How to invoke a trigger on demand?
In SQL Server 7.0 there's no way to control the order in which the triggers fire. In SQL Server
2000 you could specify which trigger fires first or fires last using sp_settriggerorder Triggers
can't be invoked on demand. They get triggered only when an associated action (INSERT,
UPDATE, DELETE) happens on the table on which they are defined.
44. What are the uses of Triggers?
Triggers are generally used to implement business rules, auditing. Triggers can also be used to
extend the referential integrity checks, but wherever possible, use constraints for this
purpose, instead of triggers, as constraints are much faster. Till SQL Server 7.0, triggers fire
only after the data modification operation happens. So in a way, they are called post triggers.
But in SQL Server 2000 you could create pre triggers also. Search SQL Server 2000 books
online for INSTEAD OF triggers.
45. What is a self join? Explain it with an example.
Self join is just like any other join, except that two instances of the same table will be joined
in the query. Here is an example: Employees table which contains rows for normal employees
as well as managers. So, to find out the managers of all the employees, you need a self join.
46. What is normalization?
The Process of organizing relational data into tables is actually referred to as normalization.
47. What is a Stored Procedure?
Its nothing but a set of T-SQL statements combined to perform a single task of several tasks.
Its basically like a Macro so when you invoke the Stored procedure, you actually run a set of
statements.
48. Can you give an example of Stored Procedure?
sp_helpdb , sp_who2, sp_renamedb are a set of system defined stored procedures. We can
also have user defined stored procedures which can be called in similar way.
49. What is the basic difference between clustered and a non-clustered index?
The difference is that, Clustered index is unique for any given table and we can have only one
clustered index on a table. The leaf level of a clustered index is the actual data and the data is
resorted in case of clustered index. Whereas in case of non-clustered index the leaf level is
actually a pointer to the data in rows so we can have as many non-clustered indexes as we
can on the db.
50. When do we use the UPDATE_STATISTICS command?
This command is basically used when we do a large processing of data. If we do a large
amount of deletions any modification or Bulk Copy into the tables, we need to basically update
the indexes to take these changes into account. UPDATE_STATISTICS updates the indexes on
these tables accordingly.
51. Which TCP/IP port does SQL Server run on?
SQL Server runs on port 1433 but we can also change it for better security.
52. From where can you change the default port?
From the Network Utility TCP/IP properties –> Port number.both on client and the
server.
53. Can we use Truncate command on a table which is referenced by FOREIGN KEY?
No. We cannot use Truncate command on a table with Foreign Key because of referential
integrity.
54. What is the use of DBCC commands?
DBCC stands for database consistency checker. We use these commands to check the
consistency of the databases, i.e., maintenance, validation task and status checks.
55. What command do we use to rename a db?
sp_renamedb ‘oldname’ , ‘newname’
56. Sometimes sp_reanmedb may not work you know because if some one is using the
db it will not accept this command so what do you think you can do in such cases?
In such cases we can first bring to db to single user using sp_dboptions and then we can
rename that db and then we can rerun the sp_dboptions command to remove the single user
mode.

57. What is the difference between a HAVING CLAUSE and a WHERE CLAUSE?
Having Clause is basically used only with the GROUP BY function in a query. WHERE Clause is
applied to each row before they are part of the GROUP BY function in a query.

58. What do you mean by COLLATION?
Collation is basically the sort order. There are three types of sort order Dictionary case
sensitive, Dictonary - case insensitive and Binary.

59. When do you use SQL Profiler?
SQL Profiler utility allows us to basically track connections to the SQL Server and also
determine activities such as which SQL Scripts are running, failed jobs etc..

60. What is a Linked Server?
Linked Servers is a concept in SQL Server by which we can add other SQL Server to a Group
and query both the SQL Server dbs using T-SQL Statements.

61. Can you link only other SQL Servers or any database servers such as Oracle?
We can link any server provided we have the OLE-DB provider from Microsoft to allow a link.
For Oracle we have a OLE-DB provider for oracle that microsoft provides to add it as a linked
server to the sql server group.

62. Which stored procedure will you be running to add a linked server?
sp_addlinkedserver, sp_addlinkedsrvlogin

63. What are the OS services that the SQL Server installation adds?
MS SQL SERVER SERVICE, SQL AGENT SERVICE, DTC (Distribution transac co-ordinator)

64. Can you explain the role of each service?
SQL SERVER - is for running the databases SQL AGENT - is for automation such as Jobs, DB
Maintanance, Backups DTC - Is for linking and connecting to other SQL Servers

65. How do you troubleshoot SQL Server if its running very slow?
First check the processor and memory usage to see that processor is not above 80%
utilization and memory not above 40-45% utilization then check the disk utilization using
Performance Monitor, Secondly, use SQL Profiler to check for the users and current SQL
activities and jobs running which might be a problem. Third would be to run
UPDATE_STATISTICS command to update the indexes

66. Due to N/W or Security issues client is not able to connect to server or vice versa.
How do you troubleshoot?
First I will look to ensure that port settings are proper on server and client Network utility for
connections. ODBC is properly configured at client end for connection; Makepipe & readpipe
are utilities to check for connection. Makepipe is run on Server and readpipe on client to check
for any connection issues.

67. What are the authentication modes in SQL Server?
Windows mode and mixed mode (SQL & Windows).

68. Where do you think the users names and passwords will be stored in sql server?
They get stored in master db in the sysxlogins table.

69. What is log shipping? Can we do logshipping with SQL Server 7.0?
Logshipping is a new feature of SQL Server 2000. We should have two SQL Server - Enterprise
Editions. From Enterprise Manager we can configure the logshipping. In logshipping the
transactional log file from one server is automatically updated into the backup database on the
other server. If one server fails, the other server will have the same db and we can use this as
the DR (disaster recovery) plan.

70. SQL Server crashed and you are rebuilding the databases including the master
database what procedure to you follow?
For restoring the master db we have to stop the SQL Server first and then from command line
we can type SQLSERVER which will basically bring it into the
maintenance mode after which we can restore the master db.

71. What is BCP? When do we use it?
BulkCopy is a tool used to copy huge amount of data from tables and views. But it
won't copy the structures of the same.

72. What should we do to copy the tables, schema and views from one SQL Server to
another?
We have to write some DTS packages for it.

PowerBI Interview Questions

PowerBI Interview Questions and Answers

Power BI Interview Questions – General Questions

1). What is self-service business intelligence?

Ans: Self-Service Business Intelligence (SSBI) is an approach to data analytics that enables business users to filter, segment, and, analyse their data, without the in-depth technical knowledge in statistical analysis, business intelligence (BI). SSBI has made it easier for end users to access their data and create various visuals to get better business insights. Anybody who has basic understanding of the data can create reports to build intuitive and shareable dashboards.

2). What are the parts of Microsoft self-service business intelligence solution?

Ans: Microsoft has two parts for Self-Service BI
 Excel BI Toolkit – It allows users to create interactive report by importing data from different sources and model data according to report requirement.
 Power BI – It is the online solution that enables you to share the interactive reports and queries that you have created using Excel BI Toolkit.

3). What is power BI?

Ans: Power BI is a cloud-based data sharing environment. Once you have developed reports using Power Query, Power Pivot and Power View, you can share your insights with your colleagues. This is where Power BI enters the equation. Power BI, which technically is an aspect of SharePoint online, lets you load Excel workbooks into the cloud and share them with a chosen group of co-workers. Not only that, but your colleagues can interact with your reports to apply filters and slicers to highlight data. They are completed by Power BI, a simple way of sharing your analysis and insights from the Microsoft cloud.
Power BI features allow you to:
 Share presentations and queries with your colleagues.
 Update your Excel file from data sources that can be on-site or in the cloud.
 Display the output on multiple devices. This includes PCs, tablets, and HTML 5-enabled mobile devices that use the Power BI app.
 Query your data using natural language processing (or Q&A, as it is known).

4). What is Power BI Desktop?

Ans: Power BI Desktop is a free desktop application that can be installed right on your own computer. Power BI Desktop works cohesively with the Power BI service by providing advanced data exploration, shaping, modeling, and creating report with highly interactive visualizations. You can save your work to a file or publish your data and reports right to your Power BI site to share with others.

5). What data sources can Power BI connect to?

Ans: The list of data sources for Power BI is extensive, but it can be grouped into the following:
 Files: Data can be imported from Excel (.xlsx, xlxm), Power BI Desktop files (.pbix) and Comma Separated Value (.csv).
 Content Packs: It is a collection of related documents or files that are stored as a group. In Power BI, there are two types of content packs, firstly those from services providers like Google Analytics, Marketo or Salesforce and secondly those created and shared by other users in your organization.
 Connectors to databases and other datasets such as Azure SQL, Databaseand SQL, Server Analysis Services tabular data, etc.

6). What are Building Blocks in Power BI?

Ans: The following are the Building Blocks (or) key components of Power BI:
1. Visualizations: Visualization is a visual representation of data. Example: Pie Chart, Line Graph, Side by Side Bar Charts, Graphical Presentation of the source data on top of Geographical Map, Tree Map, etc.
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.
4. Dashboards: Dashboard is single layer presentation of multiple visualizations, i.e we can integrate one or more visualizations into one page layer. Example: Sales dashboard can have pie charts, geographical maps and bar charts.
5. Tiles: Tile is a single visualization in a report or on a dashboard. Example: Pie Chart in Dashboard or Report.

7). What are the different types of filters in Power BI Reports?

Ans: Power BI provides variety of option to filter report, data and visualization. The following are the list of Filter types.
 Visual-level Filters: These filters work on only an individual visualization, reducing the amount of data that the visualization can see. Moreover, visual-level filters can filter both data and calculations.
 Page-level Filters: These filters work at the report-page level. Different pages in the same report can have different page-level filters.
 Report-level Filters: There filters work on the entire report, filtering all pages and visualizations included in the report.
We know that Power BI visual have interactions feature, which makes filtering a report a breeze. Visual interactions are useful, but they come with some limitations:
 The filter is not saved as part of the report. Whenever you open a report, you can begin to play with visual filters but there is no way to store the filter in the saved report.
 The filter is always visible. Sometimes you want a filter for the entire report, but you do not want any visual indication of the filter being applied.

8). What are content packs in Power BI?

Ans: Content packs for services are pre-built solutions for popular services as part of the Power BI experience. A subscriber to a supported service, can quickly connect to their account from Power BI to see their data through live dashboards and interactive reports that have been pre-built for them. Microsoft has released content packs for popular services such as Salesforce.com, Marketo, Adobe Analytics, Azure Mobile Engagement, CircuitID, comScore Digital Analytix, Quickbooks Online, SQL Sentry and tyGraph.
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

9). 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

10). What are the most common DAX Functions used?

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

11). How is the FILTER function used?

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)

12). What is special or unique about the CALCULATE and CALCULATETABLE functions?

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.

13). What is the common table function for grouping data?

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.

14). What are some benefits of using Variables in DAX ?

Ans: Below are some of the benefits:
 By declaring and evaluating a variable, the variable can be reused multiple times in a DAX expression, thus avoiding additional queries of the source database.
 Variables can make DAX expressions more intuitive/logical to interpret.
 Variables are only scoped to their measure or query, they cannot be shared among measures, queries or be defined at the model level.

15). How would you create trailing X month metrics via DAX against a non-standard calendar?

Ans: The solution will involve:
1. CALCULATE function to control (take over) filter context of measures.
2. ALL to remove existing filters on the date dimension.
3. FILTER to identify which rows of the date dimension to use.
Alternatively, CONTAINS may be used:
 CALCULATE(FILTER(ALL(‘DATE’),…….))

16). What are the different Excel BI add-in?

Ans: Below are the most important BI add-in to Excel:
 Power Query: It helps in finding, editing and loading external data.
 Power Pivot: Its mainly used for data modeling and analysis.
 Power View: It is used to design visual and interactively reports.
 Power Map: It helps to display insights on 3D Map.
Power BI Interview Questions – Power Pivot

17). What is Power Pivot?

Ans: Power Pivot is an add-in for Microsoft Excel 2010 that enables you to import millions of rows of data from multiple data sources into a single Excel workbook. It lets you create relationships between heterogeneous data, create calculated columns and measures using formulas, build PivotTables and PivotCharts. You can then further analyze the data so that you can make timely business decisions without requiring IT assistance.

18). What is Power Pivot Data Model?

Ans: It is a model that is made up of data types, tables, columns, and table relations. These data tables are typically constructed for holding data for a business entity.

19). What is xVelocity in-memory analytics engine used in Power Pivot?

Ans: The main engine behind power pivot is the xVelocity in-memory analytics engine. It can handle large amount of data because it stores data in columnar databases, and in memory analytics which results in faster processing of data as it loads all data to RAM memory.

21). 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.

22). 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.
Learn Power BI From Industry Experts
Power BI Interview Questions – Power Query

23). What is Power Query?

Ans: Power query is a ETL Tool used to shape, clean and transform data using intuitive interfaces without having to use coding. It helps the user to:
 Import Data from wide range of sources from files, databases, big data, social media data, etc.
 Join and append data from multiple data sources.
o Shape data as per requirement by removing and adding data.

24). What are the data destinations for Power Queries?

Ans: There are two destinations for output we get from power query:
1. Load to a table in a worksheet.
2. Load to the Excel Data Model.

25). What is query folding in Power Query?

Ans: Query folding is when steps defined in Power Query/Query Editor are translated into SQL and executed by the source database rather than the client machine. It’s important for processing performance and scalability, given limited resources on the client machine.

26). What are some common Power Query/Editor Transforms?

Ans: Changing Data Types, Filtering Rows, Choosing/Removing Columns, Grouping, Splitting a column into multiple columns, Adding new Columns ,etc.

27). Can SQL and Power Query/Query Editor be used together?

Ans: Yes, a SQL statement can be defined as the source of a Power Query/M function for additional processing/logic. This would be a good practice to ensure that an efficient
database query is passed to the source and avoid unnecessary processing and complexity by the client machine and M function.

28). What are query parameters and Power BI templates?

Ans:Query parameters can be used to provide users of a local Power BI Desktop report with a prompt, to specify the values they’re interested in.
 The parameter selection can then be used by the query and calculations.
 PBIX files can be exported as Templates (PBIT files).
 Templates contain everything in the PBIX except the data itself.
Parameters and templates can make it possible to share/email smaller template files and limit the amount of data loaded into the local PBIX files, improving processing time and experience .

29). Which language is used in Power Query?

Ans: A new programming language is used in power query called M-Code. It is easy to use and similar to other languages. M-code is case sensitive language.

30). 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

31). What is Power Map?

Ans: Power Map is an Excel add-in that provides you with a powerful set of tools to help you visualize and gain insight into large sets of data that have a geo-coded component. It can help you produce 3D visualizations by plotting upto a million data points in the form of column, heat, and bubble maps on top of a Bing map. If the data is time stamped, it can also produce interactive views that display, how the data changes over space and time.

32). 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.

33). What are the data sources for Power Map?

Ans: The data can either be present in Excel or could be present externally. To prepare your data, make sure all of the data is in Excel table format, where each row represents a unique record. Your column headings or row headings should contain text instead of actual data, so that Power Map will interpret it correctly when it plots the geographic coordinates. Using meaningful labels also makes value and category fields available to you when you design your tour in the Power Map Tour Editor pane.
To use a table structure which more accurately represents time and geography inside Power Map, include all of the data in the table rows and use descriptive text labels in the column headings, like this:
In case you wish to load your data from an external source:
1. In Excel, click Data > the connection you want in the Get External Data group.
2. Follow the steps in the wizard that starts.
3. On the last step of the wizard, make sure Add this data to the Data Model is checked.
Power BI Interview Questions – Additional Questions

34). What is Power View?

Ans: Power View is a data visualization technology that lets you create interactive charts, graphs, maps, and other visuals which bring your data to life. Power View is available in Excel, SharePoint, SQL Server, and Power BI.
The following pages provide details about different visualizations available in Power View:
 Charts
 Line charts
 Pie charts
 Maps
 Tiles
 Cards
 Images
 Tables
 Power View
 Multiples Visualizations
 Bubble and scatter charts
 Key performance indicators (KPIs)

35). What is Power BI Designer?

Ans: It is a stand alone application where we can make Power BI reports and then upload it to Powerbi.com, it does not require Excel. Actually, it is a combination of Power Query, Power Pivot, and Power View.

36). 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)

37). 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.

38). Is Power BI available on-premises?

Ans: No, Power BI is not available as a private, internal cloud service. However, with Power BI and Power BI Desktop, you can securely connect to your own on-premises data sources. With the On-premises Data Gateway, you can connect live to your on-premises SQL Server Analysis Services, and other data sources. You can also scheduled refresh with a centralized gateway. If a gateway is not available, you can refresh data from on-premises data sources using the Power BI Gateway – Personal.

39). What is data management gateway and Power BI personal gateway?

Ans: Gateway acts a bridge between on-premises data sources and Azure cloud services.
Personal Gateway:
 Import Only, Power BI Service Only, No central monitoring/managing.
 Can only be used by one person (personal); can’t allow others to use this gateway.
On-Premises Gateway:
 Import and Direct Query supported.
 Multiple users of the gateway for developing content.
 Central monitoring and control.

40). What is Power BI Q&A?

Ans: Power BI Q&A is a natural language tool which helps in querying your data and get the results you need from it. You do this by typing into a dialog box on your Dashboard, which the engine instantaneously generates an answer similar to Power View. Q&A interprets your questions and shows you a restated query of what it is looking from your data. Q&A was developed by Server and Tools, Microsoft Research and the Bing teams to give you a complete feeling of truly exploring your data.

41). What are some ways that Excel experience can be leveraged with Power BI?

Ans: Below are some of the ways through which we can leverage Power BI:
 The Power BI Publisher for Excel:
o Can be used to pin Excel items (charts, ranges, pivot tables) to Power BI Service.
o Can be used to connect to datasets and reports stored in Power BI Service.
 Excel workbooks can be uploaded to Power BI and viewed in the browser like Excel Services.
 Excel reports in the Power BI service can be shared via Content Packs like other reports.
 Excel workbooks (model and tables) can be exported to service for PBI report creation.
 Excel workbook Power Pivot models can be imported to Power BI Desktop models.

42). 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.

43). How is data security implemented in Power BI ?

Ans: Power BI can apply Row Level Security roles to models.
 A DAX expression is applied on a table filtering its rows at query time.
 Dynamic security involves the use of USERNAME functions in security role definitions.
 Typically a table is created in the model that relates users to specific dimensions and a role.

44). 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.

45). 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.

46). What is the Power BI Publisher for Excel?

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 .

47). 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.

48) 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.

49). 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.

50). How does SSRS integrate with Power BI?

Ans: Below are some of the way through which SSRS can be integrated with Power BI:
 Certain SSRS Report items such as charts can be pinned to Power BI dashboards.
 Clicking the tile in Power BI dashboards will bring the user to the SSRS report.
 A subscription is created to keep the dashboard tile refreshed.
 Power BI reports will soon be able to be published to SSRS portal

Connecting to Azure DataLake using SSIS

Azure DataLake and SSIS

In this article we will try to move some data from on premise system to Azure DataLake store using SSIS.

Pre-requisite

Scenario

We have DataLake Store created on Azure and we have to move data from on premise SQL Server to Azure.

Solution

You can create a DataLake store on Azure  ( http://guru-msbi.blogspot.in/2018/01/azure-datalake.html ) and provide necessary access.

Get the ADL URI from the datalake store overview.

Steps on SSIS

For moving data create two connection managers for source and destination. SQL Server source will require OLEDB source connection and DataLake will require Azure DataLake connection manager.
Before creating DataLake connection using connection manager provide user Contributor access on AC(IAM) and Read/Write access on Data Explorer.
Now add your required details on ADL connection manager as below.


Once all connection managers created then configure your source and destination accordingly.
The ADLS destination path and file details must be configured correctly as shown below.
Go to mapping tab and map columns and save the package.
You can run your package to see if the data gets loaded in ADLS as shown below.




YouTube Video











Azure DataLake

Azure DataLake 

Azure DataLake is microsoft's big data platform and is very similar to other distributed processing and storage system like hadoop or google bigquery. 
DataLake has two different part 
  • DataLake Store - Platform that provides unstructured storage (file storage, any format)
  • DataLake Analytics - This can have the structure storage which is ready for running structured query like SQL. We use USQL to query DataLake.

Steps to create DataLake Store

  • Login to Azure Portal
  • Click on +new from left top menu.
  • Select Data+Analytics and you will get list.
  • Click on Azure Data Lake Store
  • Fill in all the required details in the new window as shown below and click on create.

Setting up user permission for DataLakeStore

From all resource menu click on the newly created DataLake store.
On the menu click on Access control and select user and group from AD to provide necessary access as shown below.
To provide access to users to upload files and data follow the below step
  • Once you click on the given datalake store on the menu click on the Data Explorer option.
  • You will get a new window where click on Access and add required users provide different types of accesses like read, write, execute etc.
You can use the web URL and ADL URI to upload files and data using web interface or any application or ETL package like SSIS.



  

T-SQL LEAD LAG and SUM function based query

  Query on T-SQL window clause Below is the sales table Order_Date Name Product SubCategory ...