Jones Daniel Power BI 3 in 1 Comprehensive Guide of Tips and Tricks To Learn The Functions of Powe
Jones Daniel Power BI 3 in 1 Comprehensive Guide of Tips and Tricks To Learn The Functions of Powe
This document is geared towards providing exact and reliable information in regards to the topic and
issue covered. The publication is sold with the idea that the publisher is not required to render
accounting, officially permitted, or otherwise, qualified services. If advice is necessary, legal or
professional, a practiced individual in the profession should be ordered.
- From a Declaration of Principles which was accepted and approved equally by a Committee of the
American Bar Association and a Committee of Publishers and Associations.
In no way is it legal to reproduce, duplicate, or transmit any part of this document in either electronic
means or in printed format. Recording of this publication is strictly prohibited, and any storage of this
document is not allowed unless with written permission from the publisher. All rights reserved.
The information provided herein is stated to be truthful and consistent, in that any liability, in terms
of inattention or otherwise, by any usage or abuse of any policies, processes, or directions contained
within is the solitary and utter responsibility of the recipient reader. Under no circumstances will any
legal responsibility or blame be held against the publisher for any reparation, damages, or monetary
loss due to the information herein, either directly or indirectly.
Respective authors own all copyrights not held by the publisher.
The information herein is offered for informational purposes solely, and is universal as so. The
presentation of the information is without a contract or any type of guarantee assurance.
The trademarks that are used are without any consent, and the publication of the trademark is without
permission or backing by the trademark owner. All trademarks and brands within this book are for
clarifying purposes only and are owned by the owners themselves, not affiliated with this document.
TABLE OF CONTENTS
POWER BI
A Comprehensive Guide of Tips and Tricks
to Learn the Functions of Power BI
Introduction
Business Intelligence Software (BI)
Treatment Of Data In Power Query
The Query Editor Interface
Data Processing
Data Relationship And Modeling
Calculations And Dax
Visualization
Principles For Creating Visuals And Reports
Showing Compositions And Flows
Power BI
Sharepoint
Power Bi For Mobile
Power BI And Excel
Chapter One: Review Of Getting Started With Microsoft Power BI
Basic Theoretical Concepts
Explanation Of The Practical Example Of Power Bi
Connection With Excel File
Connection To A Web Page
Data Transformation in Power BI
Apply The Transformations Performed In Power Query
Creating A Report With Graphics
Dynamic Filters
MAPS
Chapter Two: Introduction to Power Pivot
Power Pivot Ribbon in Excel
Steps to Enable Power Pivot in Excel
Power Pivot Management Window
Excel Power BI Components - Power Pivot
Chapter Three: Introduction to DAX
Where Are We On The Road?
What is DAX?
DAX Syntax
DAX Functions
Aggregation Functions
Chapter Four: DAX in Practice
Understanding the Contexts
Row Context
Query Context
Filter Context
DAX Functions
Aggregation Functions Ending in "X
Practical Example of DAX
Using DAX Studio and Excel as Power BI Measurement Verification
Tools
DAX Studio: A Really Useful Tool
Power BI and the SSAS Service
Chapter Five: Power BI and Power Query (M Language)
The Role of BI Self-Service in the Development of a DataWarehouse
Power Query much more than Self-Service BI
Population Register. The Source Data Source
Population File Record Design
Data Import with Power BI
Query Editor. The Power Query Development
Environment
Modifying the Default Names
Optimization of Data Load Times
Creation of Columns from the Source Data
Chapter Six: Data Model Using Power Query
Nationality. Import from Excel
Chapter Seven: Power Pivot Engine To Design A Population Data
Model
Data Designer Introduction
Data Designer Population Count Measure
Report Designer Elementary Operations in the Use of Controls
Report Designer Results Display
Measurement Control Test
Tables Need Relationships
Relationships Designer. Relationship Creation
Data Designer Hierarchy Creation
Demographic Structure Indicators
Demographic Structure Indicators
Conclusion
References
POWER BI
Simple and Effective Strategies to Learn
the Functions of Power BI and Power Query
Power BI: A Disruptive Reporting Platform
Introduction to Power BI
Power BI Online Service
Power BI Desktop
Power BI Mobile
Manage Data Sources in Power BI Desktop
Benefits of Power BI
Manage Data Source
Q&A (Natural Language Query)
Strategies to Learn Power BI Functions
Introduction
Power BI Architecture
Creating, Publishing and Scheduling a Dashboard
Creating Parameters in Power BI
Calling Oracle Package Function in Power BI
Limitations in Power BI
Power BI Desktop Functionalities
Power BI Desktop Introduction
Data Connectivity Modes
Pbit Template File Implementation
Assigning Parameter Values Dynamically
Maps in Power BI Desktop
Power BI Real-Time Dashboard
Introduction
Power BI Preview
Navigation Pane
Dashboards
Dashboard Tiles
Q&A Question Box
Functionalities of Power BI Preview
Share a Power BI Dashboard
Various Data Sources
Power BI Designer File
Refresh your Data
Steps to Refresh Schedule
Power BI for Report Generation and Mail
Introduction
Setup
Report Generation Using Visualization
Publishing the Report
Subscription and Mailing of the Report
Report Creation in Power BI Desktop with AX 2012
Developing Power BI Reports with NAV 2016
Integration of Power BI Modules with MS Excel
Steps to Enable Plugins
Tips for Using the Power BI Dashboard
Dynamic Row Level Security in Power BI
Introduction to Power BI
Benefits of Power BI
Steps to Define a Role in Power BI Desktop
Toggle Button and Tooltip Features in Power BI
Introduction
Designing a Dashboard using the Imported Dataset
Toggle Button with Bookmark Feature
Report Page Tooltip in Power BI Desktop
Publishing Reports on Apps in Power BI
App Workspace
Sourcing an Existing Power BI Report into a New Power BI Report
Using Live Connection
Power BI and Share Point
Introduction
Power BI Desktop
Views in Power BI Desktop
Build Reports
Creating Charts For Sharepoint List Data Using Power BI
Integrating Power BI with SharePoint
Create Relationships between Two Charts
Create Custom and Calculated Columns in Power BI
Create a Calculated Column
Share the SharePoint Page with PowerBI Report Embedded in It
Hosting of Power BI Reports in SharePoint
Publish the Power BI Report on Dynamics 365
Power Query for Report Generation
Introduction
Setting up Power Query
Power Query for Excel
ETL Process
Synoptic Panel in Power BI Desktop
Synoptic Panel by SQLBI
Filters and Slicers in PowerBI Report
Filters in PowerBI
Different Types of Filters in PowerBI
Slicers
Slicers vs. Filters
How to Toggle in Power BI Report Using Images
Cognos Self Service BI
Self Service BI: Overview
Self Service BI: Challenges
Why Self Service is Required in Today’s World
The Business Case for Self Service BI
Need for BI Users to be More Empowered and BI Tools to be More
Exhaustive
Features and Functions
The Tradeoffs
Conclusion
POWER BI
An Advanced Guide to Learn
the Advanced Realms of Power BI
Introduction
Know Your Role in Power BI
Know More about Power BI
Chapter 1 : Power BI Building Blocks
Visualizations
Datasets
Reports
Dashboards
Tiles
Combined Together
Using the Power BI Service
Creating Dashboards using Cloud Services
Updating Data from Power BI Service
Power BI Desktop
Chapter 2 : Power BI Reports
Copy-Paste Reports
Hiding the Report Pages
Different Filter Types in Reports
How to Add Filters to Reports
Role of Filters and Highlighters
Filters Pane
Chapter 3 : High-Density Line Sampling
How Does Line Sampling Actually Work?
Tooltips in Displayed Data
Limitations in the Algorithm
Chapter 4 : Connecting with Data Sources in Power BI
Steps to Connect Data in Power BI
Import Data from Microsoft Excel
Excel Workbook Types Supported by Power BI
Connecting to Excel workbook using Power BI
Fetching Data from Power BI Desktop
Editing Parameter Settings
Chapter 5 : Power BI Real-Time Streaming
Types of Real-Time Datasets
How to Push Data in Datasets
Setting Up Real-Time Streaming Dataset
Chapter 6 : Publish Using Microsoft Excel into Power BI
How to Publish the Workbook
Publishing a Local File
Upload Option
Export Option
Reducing Workbook Size to Display in Power BI
Removing the Data from the Worksheet
Chapter 7 : Working with R Scripts
Importing Data Using R Scripts
Transforming Data Using R Scripts
Creating R Visualizations Using R Scripts
Importing Custom Visuals Using R
Getting the Best Out of R in Power BI
Chapter 8 : Working with Parameters
Connection-Specific Parameters
Connecting to Data Sources
Add Parameters to Your Filter Data
Add Parameters to Control Statement Logic
Naming Dataset Objects Using Parameters
Using Parameters in Data View
Chapter 9 : Working with SQL Server Data
Retrieving an SQL Server Table
Work with Relationships
How to Merge Datasets
Retrieving SQL Server Data Using T-SQL Queries
Make the Most of SQL Server Data
Chapter 10 : Working with Power Query M Formula Language
How to Retrieve Data from CSV Files
How to Remove Columns from Datasets
Promote the First Row to Headers
Renaming the Dataset Columns
Filtering Dataset Rows
Replacing A Dataset’s Column Values
Changing the Column Values Case
Adding Calculated Columns to Datasets
Navigate the Power Query M Formula Language
Chapter 11 : How to Visualize SQL Server Audit Data
Setting Your Test Environment Up
Generate the Test Audit Data
Creating the Connection to SQL Server Audit Data in Power BI
Desktop
Adding Tables
Adding a Matrix
Adding Visualizations
Adding a Gauge
Using Power BI to Visualize Audit Data
Conclusion
Power BI
A Comprehensive Guide of Tips and Tricks to Learn
the Functions of Power BI
DANIEL JONES
Introduction
Visualization
In the previous chapters, we have taken the necessary steps to reach this
moment: the visualization and the application of the data. We go through
the data collection and processing, we load and model it, then we create the
necessary calculations, all this process to show coherent, consistent, clean
data that answer business questions. Power BI offers dozens of visuals
between columns, bars, and stacked, horizontal and vertical, line, area, and
combination, ribbon, cascade, and scatter graphics.
Pizza charts, thread, and treemap. Real geographical maps, choleretic and
area maps. Funnel, indicators, cards, tables, matrices and segmenters.
Not only those, but there is also a Marketplace with hundreds of visuals
created by companies and experts and validated by Microsoft. Most are
free, and some have subscription services, like one of the most famous:
ArcGIS Maps. And you also have your own environment to create visuals
and program yourself in the R language.
Marketplace visuals are installed per Power BI file. This means that when
you open a new file, only the default looks will be displayed, and if you
constantly use a custom look, you must add it again (or use Power BI
template files).
To get around this problem, you can format the look (by clicking on the
"ink roller" symbol) and choose the Split formatting to show only one or
more values of those with higher representativity and still add the rest in a
category called Other . In the following example, only two of the most
representative values are shown.
After performing the previous procedure, to run an automatic filter on the
tooltip according to the axis of the visual (where this tooltip will be
configured), it is important to select "Keep all filters" in the panel below
Filters, called Tooltip (it will only be displayed after defining the page as
Tooltip).
After this procedure, go to the main report page and select the look where
you want this tooltip to appear. For example, a column graph containing
sales values by country was selected. In the Format, the Look panel, under
Tool Tip, enable the report page and select the page name with the tooltip
just below. In this example, it is called "Details." When performing this
procedure, by positioning the mouse over Y, the mini-report will appear
with the data filtered for Y.
With the panel displayed, we will navigate to the page created with the
order details and click Add. The current stage of the page will be "saved,"
considering current filters and displays. The name of the indicator created
will be "Requests."
With the indicator created, after clicking the "View Orders" button, in the
Action configuration, we must inform that the type of it will be the
Indicator and that the indicator will be the "Orders."
Classifying By Columns
The values in the axis of the visuals will be classified according to the
standard order of the column. If it is formatted as text, it will be rated from
A-Z, but if it is numeric or date, from the smallest to the largest. It is very
common to have to change the classification from one text column to
another than the alphabetical one. The nation of your classification can be
modified in modeling.
Power BI
Power BI Service is a cloud platform used to publish and share reports and
dashboards, enabling you to access them over the Internet, configure your
automatic update, manage shared workspaces, measure the usability of
published reports and dashboards, and many other features.
Your access is via app.powerbi.com, and a user and password will be
required to access your workspace. Its interface is completely different from
Power BI Desktop because they are not the same version. In fact, they
complement each other with several different usabilities. However, they
also have similarities, and for example, you can create reports, connect to
(limited) databases, and create visuals. Despite these similarities, it is not
possible to perform data processing in Power Query or create measurements
with DAX.
Its interface can be divided as follows:
1. Favorites: reports and panels can be bookmarked to be stored in
this section.
2. Recent: displays recently used reports and panels.
3. Applications: shows applications (workspaces transformed into
applications) created or obtained.
4. Shared with me: displays the reports and panels that are not owned
by this user, but that was shared with him.
5. Workspaces: are containers that store data sets, data folders, reports,
and panels.
6. The selected workspace shows the currently selected workspace and
its components.
7. Notifications: displays account notifications, dataset update,
configured alerts, etc.
Reports and shared dashboards can be viewed in the application to cellular
Power BI normally, without limitations or need for special sharing.
To view or remove the access given to users, in the same panel, click on
Access and then remove the access by clicking on the options of each user
who has access. This setting can also be performed by clicking on the
options in this report's dataset and choosing the Manage Permissions
option.
Sharepoint
A third way accessible only for Pro accounts is to insert reports into
SharePoint1. Its use is recommended for those who already use SharePoint
in the organizational environment or will start using it for Power BI reports.
To start it, the first step is to get the report link to SharePoint (different from
the web publishing link), in the File menu 'Insert in SharePoint Online.'
One of the great virtues of Power BI is the learning curve, which allows you
to transform data into information almost immediately and perform very
complex analyzes if you learn to master the tool.
This chapter is aimed at people who are faced for the first time with the
blank Power BI canvas and overwhelmed by its many options that need a
guide to get started.
The text is divided into four sections with practical guidance, and at the end
of its reading, you will know how to connect Power BI with the data
sources, transform the data and create a display panel.
On the Internet, there is more content on data visualization with Power BI
than on the transformation and cleaning of these. For this reason, I have
found it useful that the data transformation section is the most extensive and
detailed.
ETL
ETL is the acronym for extraction, transformation, and load (in English:
extraction, transformation, and load), which is the process that allows us to
obtain data from multiple sources to transform and clean them and then
upload them to Power BI.
The ETL process is necessary so that the data we use to mount our graphics
are in the right conditions (suitable formats, without errors or blank fields,
etc.).
Power Bi Elements
Power Query: is the ETL tool integrated into Power BI.
Power BI Desktop: the desktop version of Power BI to mount the
reports.
Power BI in the Cloud: view, share, and modify models created in
Power BI Desktop.
Power Bi Languages
Language M: it is the programming language of Power Query, but do not
worry, the editor that includes the program allows you to do almost
everything without knowing how to program with this code.
DAX language: it is the equivalent to Excel formulas within Power BI, but
much more powerful. Even if you do not master it, it is advisable to learn
the use of formulas that are useful for improving your reports.
Measurements
In a very simplified way, we can say that the measurements are the
calculations made using the “formulas” of Power BI (DAX language), with
the advantage that once created a measure, we can use it as many times as
we want in our report.
We will see it more clearly in the example.
Data Connection
There are multiple options for connecting to cloud services, databases, web
pages, etc. In this case, we will connect to an Excel file and a web page.
To do this, click on the “Use the first row as header” button on the “Start”
tab.
With this step, you have already achieved that the table has the correct
headings and is ready for the next transformation.
Reproduce these same steps in the “World Population” and “Urban
Population” tables before continuing with the practice.
A reminder of the steps to reproduce:
Delete the first two rows.
Use the first row as a header.
Attach Tables
The next step is to join the three tables to which you have eliminated the
unnecessary rows. All three tables must have the same number of columns,
and their names must match.
Click on the "Append queries" button on the "Start" tab and select the
option "Attach queries to create a new one."
In the pop-up window, choose the "Three or more tables" option and select
the "Active population," "World population," and "Urban population" tables
by pressing the "Add" button.
When the three selected tables are in the “Tables to append” area, click on
“OK.”
This action creates a new table that contains all the rows of the previous
tables.
Recommendation:
This function is very useful if you have an Excel file for each month of the
year because it allows you to put them all together in the same table.
Delete Columns
Our table “World Bank Data contains the column “Indicator Code” that we
will not use and, therefore, we can eliminate.
Select the column and click on the "Remove" option from the pop-up menu.
Filter Rows
Looking closely at the table, you will see that some rows do not have the
name of the country. For example, rows with code "ARB" have a country
name "null."
This is because “ARB” is not the code of a country and does not appear in
the Wikipedia table. The Excel files with the World Bank data contain
subtotals, and “ARB” is the sum of all the countries that belong to the Arab
World.
As we want to work with country data, we will filter all the rows that are
not. Stop it by pressing the filter button in the "Common Name" column
and unchecking the "(null)" value.
This will hide rows that do not correspond to countries and will not appear
on the Power BI Desktop graphics display screen.
Dynamic Filters
The next step is to add a filter that allows you to select countries. Click on
an empty place on the canvas to make sure the graphic is not selected and
then choose the “Data segmentation” display.
The empty display will appear on the canvas, and you must select the
“Common Name” field from the “World Bank Data” table to transform it
into a country filter.
Click on different countries to see how the graph behaves. You can also
select several countries at once if you press and hold the keyboard control
key.
MAPS
Now take the visual object "Choropletic map Map" to the canvas.
Then place the country in the field "Location" and% of the urban population
in the field "Information on tools."
Then create a filter with the year field as you did before with the name of
the countries.
You should have a structure similar to the one in the following image.
Finally, we will format the map, selecting it and clicking on the roll of the
visualizations section (remember to select the map, or you will be
formatting the filter of years).
Left-click on the symbol with three vertical dots in the “Data colors” menu
and click on the “Conditional formatting” button.
In the pop-up window, configure the following fields:
Format by: Color scale.
This way we will make the colors of the countries vary according to the
number of inhabitants.
Depending on the field:% Urban population
Minimum: Lowest value à white
The country with the least urban population will appear on the map in
white.
Default format: Specific color to black.
Thus we will see in black the countries that do not have data in our Power
BI table, and we will be able to detect possible errors.
Maximum: Highest value to red
The country with the most urban population will appear in red.
You can now click on “Accept.”
To test the graph, select the year 2017, and you will see that there is little
color contrast that facilitates the interpretation of the map.
To achieve greater visual contrast, press the conditional format found in
“Data colors” again.
In the format window, check the box "Divergent," and the color scale will
be modified by adding the yellow color.
Pressing on the control key and moving the mouse wheel, you can zoom in
the map to enlarge specific areas.
Power BI is a very powerful tool with countless options, and this book
intends to be a guide so you can get started in application management.
The consultancy Gartner carries out a classification of the main analytics
and business intelligence providers every year, and Microsoft has been
leading it for several years, so you can rest assured that all the effort you
dedicate to learning to manage Microsoft Power BI will be well spent.
Chapter Two:
It occupies a size of only 26.3 MB. Note that the compression may be
lower, as it depends on the redundancy of values in each column, and in this
case, the redundancy is quite high.
In addition, it includes a powerful formula language called DAX (Data
Analysis Expressions) that greatly increases the analytical calculation
capacity and response speed.
Whether you are a mid-level Excel user and are getting your company data
by exporting reports and queries from your applications and/or by copy and
paste operations. And if you are an advanced user who discovers and
struggles every day with the VBA language to try to obtain analytical
solutions with some dynamism and without having to do tedious and
repetitive manual tasks to obtain updated data from your company and
transform it for analysis, Power Pivot is the tool you need to make your life
easier, spending less time on tedious tasks and more time analyzing your
information and making better decisions.
In short, more storage, easier access to external data, greatly increased
calculation speed and a new formula language with much more computing
power. Power Pivot is the new end-user-oriented information storage and
analysis tool that is fully integrated with Excel. As you can see in the
following image, its interface is a new menu in the Excel ribbon.
Home Menu
Creation of Hierarchies
To create a hierarchy you must be in the diagram view and click on the
specific table you want to create the hierarchy on, and you will see that it is
marked in a different color and that two icons appear at the top, to the right
of the table name, you must click on the icon, then you must assign a name
to this hierarchy and drag columns from the same table to create the
different levels we want it to have. Note that a hierarchy cannot use
columns that belong to another table than the one you created.
Menu 'Design'
Group of options ' Columns ': they are options related to the treatment of
the columns of a table in the Power Pivot Management window.
Add : allows you to add calculated columns to a table. This option
will be seen in detail when we study the DAX part.
Delete : it allows you to delete columns from a table.
Freeze : allows fixing columns, so that they remain visible when
scrolling horizontally. It does not affect at all how users will see it in
the pivot tables, and it only affects the display of the table in the
Power Pivot Management window.
Width : allows you to adjust the width of the column in pixels. It
only affects the display of the table in the Power Pivot Management
window.
Group of options ' Calculations ': these are options related to the execution
of calculations using DAX expressions.
Insert Function : applies to the formula bar, it helps us when
writing DAX expressions, allowing us to use a search form about
the available functions.
Calculation Options : Allows calculations to be performed
automatically, i.e., every time you enter or change a DAX
expression, the values are recalculated. The advantage is that you
have the result immediately, but the more DAX expressions you
have in the model, the slower any change is made (it recalculates all
of them, not just the one you have modified). Therefore, from here,
you can change the option to 'Mode Manual calculation,' so the
calculations will only be made when you decide, that is, when you
press the option on that same button, called 'Calculate now.' It is
common practice to remove the 'Calculation automatic' while we are
designing the models, thus achieving shorter waiting times when
writing DAX.
Group of options ' Relationships ': these are options related to the
management of relationships between tables.
Create Relationship : a relationship is established based on a
column in a table that is related to another column in another table.
Both have to be the same type of data. This is the form that allows
us to create a relationship.
Manage Relationships : allows you to create, modify, or delete
relationships.
You can also create relationships from the ' Diagram View ' by clicking on
the source column of the relationship and dragging and dropping on the
target column of the relationship, as shown in the image:
Releasing the mouse will create the relationship between these columns in
both tables.
Relations - besides being between columns of different tables and having
the same type of data, we must coherently create them. For example, even if
the product code is numerical and the supplier code is also numerical, there
is no point in establishing a relationship between the two (even if the tool
allows me to), and we would get totally false and inconsistent analytical
data.
Therefore, when establishing relationships, we are going to do so based on
the relationships defined in our documentation of the model, which is where
it is already studied in detail and set down in writing what relationships
there should be between the tables of the model and through which columns
they are to be carried out, all of this applying the good modeling practices
studied. Here we will merely do the operational part of physically creating
them in Power Pivot based on the documentation.
Next, we are going to mention a series of limitations that we have when
creating these relationships, and that partly affect the design of the model,
although if we follow the good modeling practices studied, we will be given
this casuistry in fewer occasions:
Only one column can be used for each table involved in the
relationship. Although this aspect is reflected in the form, where
you can only select one column, we want to highlight it here
because other tools allow several columns from each table to be
involved in the relationship.
There can only be one active relationship between two tables. For
example, if I have a sales table with three dates (sale date, shipment
date, and collection date) I will have to establish a relationship for
each of these columns with the table of the dimension 'Date,' but
only one of them can be active, leaving the other two as inactive. An
active relationship is the one Power Pivot uses by default to obtain
information from two related tables. If we need to use an inactive
relationship, we will have to do it using DAX expressions in which
the inactive relationship to be used is expressly indicated.
It only allows for one-to-one or one-to-many relationships.
Relationships between two columns in the same table are not
allowed (self-referenced relationships).
Circular relations are not allowed, that is, if table1 is related to
table2 and table2 to table3, table3 cannot be related again to table1.
Option ' Table Properties ': allows you to edit the table properties. As we
explained before, there is no designer for this, but the structure of the table
comes from the result of obtaining and transforming data from Power
Query or from the options to 'obtain external data' included in Power Pivot.
If we have used Power Query, in the form, you cannot make any
modifications to the process made with Power Query, but you have to go to
Power Query and make the appropriate changes. If the process was done
with any of the options in the menu ' Get External Data' of Power Pivot,
from here, we would have access to consult and modify it.
Option ' Mark as Date Table ': allows you to select which is the Date table.
This table corresponds to the Date dimension, which we studied in detail
previously. With this option, we must assign this table and mark which
column has the data type Date. From that moment on, the time intelligence
functions that are part of the DAX language are enabled. Basically, in
Power Pivot, at the model creation level, you only have to make this
assignment. The bulk of the work is to include in the dimensional model a
'Date' dimension that compiles all the time treatment needs of each business
and, later, to include the calculations through DAX expressions that help to
enrich the analysis.
Group of options ' Edit ': these are options to redo and undo.
Undo : undo.
Redo : redo.
'Advanced' Menu
Introduction to DAX
DAX Syntax
Excel's formulas are oriented to calculations based on cells and ranges of
these, for example, in cell A21, we can write the following expression:
=SUM(C1:G1)
We also have a new syntax, incorporated in the latest versions of Excel, that
applies in the case that we have formatted a set of cells as a table, which
allows us to reference columns in the table using the format "
[@ColumnName]." Note that in tables, you can use both the traditional cell-
based syntax and the new column-based syntax.
Why are we talking about these two syntaxes here? So to facilitate the
introduction to the DAX syntax, which is more similar to the syntax we just
saw, based on tables, although with some peculiarities:
It is only allowed to reference columns in tables, and there is no cell
concept .
It can be applied to calculated columns, calculated fields
(measurements), and KPIs.
In the case of calculated fields (measurements), the syntax includes
the name of the new field.
KPIs do not allow the use of table columns or calculated columns,
and they only allow the use of calculated fields (measurements).
Calculated fields are the new name given to what used to be called
Measurements as of the 2012 version. It is simply a name change; the
concept, functionality, and features remain the same. Here we will use the
new name and in parentheses the old one, as you should know both, and
you will find a lot of documentation on the internet using the term
"Measures."
In DAX: Calculated fields = Measures
Where are the DAX formulas written? Within the Power Pivot window,
although it is located in a different place and with certain nuances in the
syntax, depending on whether it is a calculated column or a calculated field
(measurement).
The Syntax for Calculated Columns
It is similar to sets of cells formatted as tables:
= "Expression."
= FUNCTION ("Expression1" ; "Expression2" ; ... )
To refer in any expression to the columns of a table, we will use the format
'Table' [Column], and follow the following rules:
Single quotes " ' " are optional when indicating the table, they are
only mandatory if the table name contains spaces or special
characters:
Customers' table, Customers
If the table column used in the calculated column expression
belongs to that same table, it is optional to enter the table name:
'Sales Table' [SalesAmount], Sales [SalesAmount],
[SalesAmount]
Brackets are mandatory. It is the form that identifies that we are
referring to a column in the table.
'Sales Table' [SalesAmount], Sales [SalesAmount],
[SalesAmount]
The input of the calculated column expressions is done in a text box that is
right at the top of the table, very similar to where you enter formulas in
Excel. Once the expression has been entered, to change the name of the
calculated column we right-click on it and choose the option "Change name
of column" (this is the way to do it, since the name of the calculated column
is not part of the DAX expression).
When we are writing an expression for a calculated column, we always get
a contextual help that makes the task easier.
Calculated Columns
A Calculated Column is a column that is added to an existing Power Pivot
table, using a DAX expression that defines it. The value of the expression
used is calculated for each row of the table at the same time it is created (at
model design time) and then updated when the source data is updated (by
pressing the " Refresh " button).
You can create calculated columns based on other calculated fields
(measurements) and other calculated columns.
The calculated columns are added to the right of the columns we have
extracted from the data source and automatically assigned the names
CalculatedColumn1, CalculatedColumn2, and so on. Although you can
rearrange the order of the columns by clicking on them and dragging them
to the desired position, you can also rename any calculated column by right-
clicking on it and choosing the option "Rename column."
Its values are stored on disk and in memory in the same way as any
other column in the table. Technically they are known as "materialized" or
"persistent." They are designed to be static.
The calculated columns can be used later in Excel:
Segmenters ( Slicers )
Filters
Rows
Columns
Values
Let's look at some examples of use:
Calculate the year (or any other date-related calculation) in a new
column=YEAR ([Date])
Concatenate the serial number and invoice= [Serial ]&"#"
[Invoice]
Calculate the Margin= [NetPrice] - [PriceCost]
Get a column from another table=RELATED (Province
[Provincial])
It's one more technique to denormalize
When we drag a column into the value area, something happens internally
that we must understand, really what Power Pivot does is to create an
"Implicit Calculated Field," this happens whenever we drag a column of a
table, whether it is calculated or not, to the value area.
An Implicit Calculated Field is one that does not originally exist but is
automatically created when you drag a column into the value area. From
then on it exists as one more field which by default is assigned the
aggregation function SUM and its default name is "sum of
Calculated_Column_Name". For example, if you have the SalesAmount
column and drag it into the value area for the first time, the calculated field
"Sum of SalesAmount" will be created automatically.
An Explicit Calculated Field is one that we create in design time in Power
Pivot in the grid designed for it. Next, we will study in detail the calculated
fields (measurements).
At this point, we ask ourselves the following question that has several
answers, with its pros and cons: Where should I perform the calculations,
with SQL when asking for information from the source, with Power Query,
with calculated columns?
With SQL, we have two disadvantages, we need to know SQL language (it
is evident), and in addition, the information is calculated in origin
consuming resources of the server and traveling by the network once
calculated. We do not recommend it in this case.
With Power Query, it is calculated during the execution of the data update
process, it is done already at the destination, in the computer where it is
running, and the column is stored like any other column in the source (we
are not really able to distinguish when we are looking at the column
information in Power Pivot if a column exists in the source or is calculated
with Power Query. This is a good alternative, leaving all that calculation
logic in Power Query, it has the advantage that if I need certain columns
only for the calculation I can use them in the process and they don't have to
get to the model in Power Pivot.
Using calculated columns, the DAX calculations are quite efficient, but on
the other hand, it forces me to bring the columns involved in the calculation
into the model and thus take up unnecessary space. What we can do is hide
them from the user so that he does not see them.
DAX Functions
We are going to start with the study of some of the basic and most common
DAX functions, and then go into more detail and additional concepts that
we need to be clear about to obtain the best analytical result.
Aggregation Functions
There is another group of functions, the Aggregation Functions, which
come from the relationship of functions inherited from Excel and will make
it easier for us to begin to understand the differences between traditional
Excel and Power Pivot.
Aggregations allow you to contract, summarize, or group data. They are in
charge of calculating a column from the maximum level of detail of its
rows, affecting in principle all of them unless we indicate some kind of
filter or descriptive breakdown.
Let's see an example, and if we want to know the total sales of the company,
we will create a column calculated using the SUM() function.
So far, nothing new, we have already seen this function in previous
examples, and it gives us the sum of all the values in the column "
[SalesAmount]."
Let's now see what we have achieved by writing such a simple function for
visualization and use in a pivot table. Note that we have also applied to
format so that it always shows two decimals and the thousands of separators
(how to do this was studied earlier).
If we create a pivot table connected to our model in Power Pivot and drag
"TotalSales" to the value area, it shows us the result of adding "
[SalesAmount]" for all the rows of the table and already formatted.
Now we break it down into a row for each store, and we break it down
again with a column for each year.
And finally, we added a filter to have only the sales of "single" customers
(Marital Status=Single):
How many DAX formulas have you had to perform to obtain all this
information regarding the company's sales amount?
JUST ONE!!! And keeping the same value in the
But, if you had used the SUM function in traditional Excel, how many
times would you have had to change the cell ranges of the parameter that
passes to that function to get that result? It's not even worth counting them,
obviously one for each change.
That is where one of the elements that give that computing power and
flexibility to perform analysis resides. But this is not the only element; later
on, we will go deeper and understand why this behavior is so simple after
creating a calculated (measured) field in DAX.
We will now explain the different types of aggregations that exist and the
functions in each of them:
Additives : They add without restrictions.
Functions: SUM, COUNT, COUNTROWS, AVERAGE
Semi-additives : They only add-in part, let's see an example: we
need to know the total number of different customers who buy in
our stores, we know that in January there have been 200 customers,
in February there have been 225 customers and in March 210; on
the other hand, if what we want to know is the total number of
different customers who buy in our stores in the first quarter, we
cannot add it up as it is, because there will be customers who have
bought from us during the three months of this quarter and others
who have not, therefore it will be a number between 225 and 635.
Functions: DISTINCTCOUNT
Non-additive : Cannot add.
Functions: MIN, MAX
Customized : we decide through various DAX expressions how
they should act. For example, if we want to calculate a balance
sheet, there will be accounts that add and accounts that subtract.
Functions: there are no specific ones; we will have to create
more complex DAX expressions that solve each need
individually.
The following table shows the syntax of these functions and a brief
description. For more details, you can see the product's help.
RELATED(<Column>)
It returns a related value from another table
column following the M->1 relationship.
Example: add a column calculated with the "
[Population]" to the "Store" table (Many
Stores -> 1 Population):
=RELATED(Geography(Population))
DAX in Practice
Row Context
It applies to the elements in the row in question, the "current row." It is
used, among others, in the calculated columns. It covers the row being
calculated and the rows of other tables related to that row.
It behaves like the Excel formulas applied inside a table, automatically
referring to values in the same row. If the table is related to others, you can
access any value in those tables that are related to the current row. To access
these related tables, we have the RELATED function explained above.
There are other types of cases for which DAX has a series of functions that
iterate, in a kind of internal loop, the calculations on a table. For the time
being, it is sufficient to understand the above and to lay down a good
foundation.
Query Context
It evaluates a dataset for a specific cell. It refers to a subset of data that is
implicitly retrieved for formula and allows elements to be added to the
filter, row, and column areas.
When you place a calculated field or a column with numerical values in the
value area of a pivot table, the Power Pivot engine examines the column
and row headers, data segments, and report filters to determine the context.
Power Pivot then performs the necessary calculations to fill each cell in the
pivot table. The data set that is retrieved is the context of the query for each
cell.
For a calculated field (measurement), it is the one defined by the row and
column, plus the filters applied from segmenters ( slicers) and filter areas.
Let's look at a simplified sales example, with a very reduced number of
rows and columns to understand it better. To analyze the sales, we have put
in rows the dates, in values the calculated field "Sum of the amount"
(implicit calculated field), and we have added two segmenters, one for
Customer and another for Product.
In the table, you will see the cells read by the Power Pivot engine to obtain
the value that appears calculated in the dynamic table on the right (light
blue and white).
Filter Context
It is applied to the row and query contexts to generate exceptions and allow
us to vary the evaluated cells based on our needs. That is, it allows you to
reduce or extend the row context ( Row context) and query context (Query
context) using additional filters applied in the DAX functions
There are many cases in which we must apply additional filter contexts, but
to understand this we are going to make a simple example in which we are
going to calculate the sales ratio of each client concerning the total sales of
the company, for this, we are going to define the following calculated
fields:
TotalImport:=SUM([Amount])
TotalCompanyImport:=CALCULATE([TotalImport];ALL(Sales2))
RatioSales:=DIVIDE([TotalImport]; [TotalCompanyImport])
Note that "TotalImportEnterprise" is always 656. Later on, we will study
the CALCULATE and ALL functions, as well as other functions that allow
us to perform filter contexts.
As you can see, we have applied the good practices of creating fields
calculated with simple calculations and reusing them. It is preferable to do
this with the three calculated fields shown above than with the following
expression:
RatioSales:=DIVIDE(SUM([Amount]);
CALCULATE([TotalAmount];ALL(Sales2)) )
Both for the simplicity of understanding them, and for their subsequent
reuse, if we do it as we initially proposed, we will be able to reuse the
calculated fields "TotalImport" and "TotalImportEnterprise" in any other
calculation we need to do, and if there were any error just correct it there
would be automatically corrected all the calculated fields that include them.
DAX Functions
Once we have laid the foundations, we can learn any DAX function and
apply it correctly. Here are some frequently used ones, which are also often
used in combination with other existing functions.
CALCULATE() Function
The CALCULATE function evaluates an expression in a context that has
been modified by the filters passed to it as parameters. Its syntax is:
CALCULATE(<Expression>;<Filter1>;<Filter2>;...;<FilterN>)
All the "Filter" parameters applied for work as if they were within a Y() (
AND()) function, that is, the expression will only apply to the rows that
comply with all the filters.
As this definition can tell you little at this time, let's see with other words
more understandable for any Excel user. CALCULATE is like the
SUM.SI() function, but its power and flexibility has been increased almost
inexhaustibly. But what does this really mean? So the function
CALCULATE instead of applying only to "ADD" applies to any DAX
expression we pass to it as the first parameter, and instead of the condition
"YES," it applies to all the filters we pass to it as a parameter. Remember
that the concept of the filter is used only to select a part of the selected
values, but it is a switch to filter context, so you can select several rows that
is higher than the filtered ones at a given time.
We are going to show a very basic example by emulating the function
SUM.SI(), which although not very useful, will help us to understand better
the function CALCULATE:
SumImportP2:=CALCULATE(SUM([Amount]);
Sales2[Product]="P2")
SumImportP2:=CALCULATE(SUM([Amount]); FILTER(Sales2;
[Product]="P2"))
The two expressions above are equivalent. We have used an addition
expression and applied a filter so that it only adds up the amounts of the
product "P2".
Let's take up the example we saw earlier when we explained the Filter
Context, and now we will be able to understand it in detail:
TotalImport:=SUM([Amount])
TotalImportCompany:
=CALCULATE([TotalImport];ALL(Sales2))
We have used an addition expression and applied a filter context, so that
instead of applying the filters defined by the user in the pivot table, always
apply to all the rows of the table 'Sales2', since the function ALL() here
means "return all the rows of the table sales2 without filtering".
Next, we will explain the keys to the operation of CALCULATE, to do this,
we must understand how the filters behave:
The "Filter" parameters change the context of the pivot table, by changing it
to filter context:
If the filter argument acts on a field that "Already" is in the pivot
table, it overrides that context and activates the filter context.
If the filter argument acts on a field that "No" is being used in the
pivot table, it adds it to the filter context.
Let's look at a third example of the use of the CALCULATE function. In
this case, something that has a certain complexity and poor performance in
relational database systems, but here it is done very easily and very well.
We need to know the accumulated sales from the beginning of time to a
given date; for this, we use the following expression DAX:
Accumulated Sales:=CALCULATE([TotalSales];
FILTER(ALL(Date); Date[DateSK] <= MAX(Sales[DateSK]) ) )
Time Intelligence Functions
Most of today's analytical systems incorporate several advanced time
management features. In this case, Power Pivot and DAX will not be less,
also incorporate them. This set of functions allows us to manipulate periods,
which is a very common requirement in BI.
There is a simple but important requirement that we must take into account,
to apply them, we need to have a column whose data type is "Date."
The time functions allow us:
Get specific dates.
Get a set of dates.
Evaluate an expression over a specified period
There's a group that returns on a particular day, some of these are:
FIRSTDATE(DateColumn)
LASTDATE(DateColumn)
FIRSTNONBLANK(DateColumn, Expression)
LASTNONBLANK(DateColumn, Expression) S
TARTOFMONTH(DateColumn)
ENDOFMONTH(DateColumn) Etc.
We are not going to study them one by one since they are functions that
either by their name or because they exist in Excel, are very simple to
consult in the help and start using them.
There's another group that returns a set of dates, some of which are
DATEADD(DateColumn, Interval number, interval)
DATESBETWEEN(DateColumn, StartDate, EndDate)
DATESINPERIOD(DateColumn, Interval number, interval)
PARALLELPERIOD(DateColumn, Interval number, interval) Etc.
Here is an example that will help us understand the usefulness of this type
of function. It is very common that when we are working with a period, we
want to see the result that was obtained in the same period of the previous
year, for this, one of the functions that we can use is PARALLELPERIOD:
TotalSales:=SUM([AmountSales])
SalesPreviousYear:=CALCULATE([TotalSales];
PARALLELPERIOD(Date[Date];-1;year))
SalesPreviousQuarter:=CALCULATE([TotalSales];
PARALLELPERIOD(Date[Date];-1;quarter))
And finally, we'll see a third group that evaluates an expression over some
time:
TOTALYTD(Expression, DateColumn, Filter) -- Year
TOTALQTD(Expression, DateColumn, Filter) -- Quarter
TOTALMTD(Expression, DateColumn, Filter) – Month Etc.
Let's see an example of the use of TOTALYTD and TOTALQTD, which
allows us to make accumulated sales within the current year, initializing to
zero automatically for each year.
TotalSales:=SUM([AmountSales])
TotalCurrentYear:=TOTALYTD([TotalSales]; Date[Date])
In the following image, you can see the result obtained:
Youth Population =
CALCULATE ( [Total Population], Age [AgeID]> = 0 && Age
[AgeID] <= 14 )
Adult Population =
CALCULATE ( [Total Population], Age [AgeID]> = 15 && Age
[AgeID] <= 64 )
Major Population =
CALCULATE ( [Total Population], Age [AgeID]> = 65 )
Let's start by adding the Total Population and Young Population measures.
Then, using the means offered by Power BI, if we wanted to verify the
validity of the measurements, we would use Visual Card and Multi-row
card controls, to observe the total values, or Table or Matrix controls, to
analyze the numbers disaggregated by the elements of some of the search
tables of the model.
However, this procedure will seem somewhat cumbersome to carry out if
we already have experience in the development of multidimensional cubes
or tabular models, in which, simply by opening Excel and connecting to the
model, we already have a dynamic table with which to check the measures
we have created.
For this reason, we propose a technique explained by Matt Allington in his
blog, where in addition to Power BI, the use of Excel and DAX Studio is
required, working all the elements in a coordinated way to achieve our goal.
S ince its entry into the arena of business intelligence tools, Power BI has
rapidly climbed positions within this segment of data analysis and
decision-making systems development, to position itself as one of the most
interesting options that They exist today thanks to a numerous set of
qualities, among which a powerful capacity for graphical representation of
the resident information in the data model, as well as the integration into the
Power Query product, the extraction, transformation and loading engine
(ETL) also included in Excel.
Precisely, the data mentioned above cleaning and debugging processes
represent one of the main pillars of the phases that make up the
development of an information system, so having a powerful and versatile
tool to perform these operations is essential. Power Query, thanks to its rich
user interface, which allows us to carry out the most varied operations of
transformation and adaptation of the source data, gives Power BI a great
power in the preparation of the data that we will later model using Power
Pivot (DAX), to convert them into accessible information through
dashboards, reports, etc.
In the following figure, we can see a broad graphical representation of the
different phases that constitute the development of an information system
using Power BI.
And if this were not enough, where we cannot reach the operations
available in the user interface, Power Query also offers us the possibility to
schedule tasks through M, its formula language, which considerably
expands the range of options at our disposal.
Query Editor.
The Power Query Development Environment
Query Editor will be our main window of work throughout, and it is
recommended that we familiarize ourselves with the elements.
You want Container panel of the queries used in the data transformation
operations, which will later be used as a basis in the construction of the
model from the Power BI designers. The term Query (query) serves the
Query Editor to identify mainly tables, lists of values, or other types of
objects that store data in a structured way. The work to be developed in this
here will be focused mainly on the management of tables, so we will use
both terms, query, and table to refer to the same type of object: a structure
of data organized in rows and columns.
Data. This area shows the content of the query currently selected in the
Queries panel.
Applied Steps Each of the operations we carry out on a query represents a
step in the set of transformations performed, being registered with a name
in this block of the Query Settings panel. This allows us to place ourselves
in any of the steps to check the status of the query at that precise moment,
modify it, delete it, etc., as if it were a macro recorder.
Formula Bar. Expression in M language corresponding to the currently
selected step. If this element is not visible, we will activate it by checking
the Form Bar box of the Layout group on the View tab.
Operations menu It is an impressive toolbox where we will find all kinds of
debugging, cleaning, transformation, etc. We need to apply to the data. Let
us also keep in mind that if we do not find the solution we are looking for,
the possibility of entering our own code in M language is always available.
This leads us to look for the solution in the Custom Column option, also
located in the Add Column menu tab, which, as the name implies, enables
the creation of a custom column by entering an expression written in M
language.
if Text.Length (Text.Trim (Text.Range ([Individual], 2,3))) = 0 then
"999"
else
Text.Range ([Individual], 2,3)
In the previous block of code, we use the decision structure if… then… else
and functions belonging to the Text category to check if there is value in the
3-character substring that starts at index 2. Note that in a case like the
current one, where we perform several functions in a nested way, the order
of evaluation of the same begins with the one that is located in the
innermost position continuing outwards, as explained below.
First, we extract the substring using the Text.Range function, then we
eliminate the blank spaces that could be with the Text.Trim function, and
check the resulting length with the Text.Length function; if this is 0 (empty
string) it is one of the bleached municipalities, so we return the 999 string
as a result (the double-quote character is used as a string delimiter);
otherwise, it is a municipality with value, and we return the substring
corresponding to its code through Text.Range.
How do I find the most appropriate function for each moment? The answer
is inside
M is a language composed of functions, which organized into categories
(Table, Text, Number, List, etc.) offer a wide spectrum of possibilities for
handling tables, lists, character strings, etc.
But in the face of such an offer, we need some type of documentation to
find the one that best suits our requirements in each situation.
As resources on the Internet, we have the official Microsoft reference page,
from which we can download a document with the language specifications.
For the functions, there is also a page where they are grouped by category,
and we can also find many sites dedicated not only to Power Query, but also
to Power BI, Power Pivot and other Microsoft BI technologies, of which in
the end some featured links are provided.
However, all of the above resources are based on our availability of an
Internet connection, but what happens if, under certain circumstances, we
cannot connect to the Network?
This situation should not worry us since from the Power Query itself, and
we can access information about the functions of the M language through a
small trick.
First, we will create a new query using the New Source | Blank Query,
located in the Home menu, New Query group.
A new query with the default name Query1 will be created. In the formula
bar, we will write the following expression.
= #shared
After pressing Enter, a result set consisting of records (Record objects)
containing the language functions, as well as types, constant values, etc.
will be generated. To be able to handle this list more comfortably, we will
click on the Into Table menu option of the Convert group, belonging to the
Record Tools | Convert, to convert it into a table type query.
Once the table is obtained, we can find information about the functions by
applying a filter on the Name column. For example, if we want to see only
the functions of the Text category, we will click on the filter/order button of
that column, we will enter the Text value. (including the point to narrow the
search better), and we will click, OK.
As a result, the table will show the names of the filtered functions. We can
reopen this filter box and apply it for ascending order.
But if the aid remained only in a list of functions, this utility would be
impractical. We are going to look for in this list one of the functions that we
have previously used: Text.Range, and in the Value column, we will click
but not on the Function value but in an empty space within that box. A
panel will open at the bottom of the window with detailed information
about the selected function: signature (parameters and return with their
corresponding types), description of the operation performed, and examples
of use.
If we click again, this time on the Function value, the information on the
function will be expanded, covering the entire window and opening the user
interaction dialog box so that we can evaluate its operation.
We can also use other filter variants, such as the search for functions that
contain a specific substring within their name. First of all, we will remove
the last steps created in the Applied Steps panel until we remain in
Converted to Table. Deleting a step is very simple, just select it and press
Delete or click on the delete icon next to its name.
Then we will open the filter box again, and in the Text Filters option, we
will select Contains, entering the ToText value in the filter box. After
accepting this dialog box, we will obtain it. As a result, all the functions
whose name contains the introduced particle.
Once we finish consulting the documentation using these techniques, we
can select the Query1 table in the Queries pane and delete it by pressing the
Delete key.
Nationality
The nationality code data, which we will transfer to a column with the name
NationalityID (Text), is in positions 12, 13, and 14.
Nationality ID
=====================
Nationality. Set Column Headings from the First Row of the Query
After changing the name of the query for Nationality in the Queries panel,
we have to replace the current column titles (Column1 and Column2) with
names that adequately describe their content.
One possibility is to reuse existing names in the Excel sheet from which we
have imported this data. These names are currently in the third row of the
table, so we will remove the first two rows (which do not contain valid
information) using the menu option Remove Rows | Remove Top Rows,
from the Reduce Rows group, Home tab, which will show a dialog box in
which we will enter the number of rows to delete.
As a next step, we will transfer the values of the first row of the table to the
column titles, using the Use First Row as Headers option, of the Transform
group, Home menu tab.
We have explained this technique of assigning names to the headings of a
table simply for demonstration purposes so that the reader knows the
existence of this possibility. However, we will not reuse the column titles of
the source Excel file, but we will assign new names explicitly; so in this
table, we will change the names of the columns by NationalityID (Text) and
Nationality (Text), by right-clicking on each title and selecting the Rename
option.
This table also contains a significant amount of empty records at the end,
which we will delete using the menu option. Remove Rows | Remove Blank
Rows, from the Reduce Rows group, Home tab.
Then the Merge window will open, which in its upper part shows the origin
table of the crossing: MunicipalityResidence. We will also have to select the
ProvinceResidence table at the bottom, and in both the crossing and union
field, which has the same name in the two tables: ProvinceResidenceID.
The type of crossing or Join Kind, which in this case is Left Outer, indicates
that for the operation, all the rows of the first table, MunicipalityResidence,
and those rows of the second, ProvinceResidence, in which there is a match
will be used. The last element of this window is an informational message
with the number of rows between which there has been a match, and which
in this example has been for all rows.
The consequence of this union operation when accepting the Merge window
will be the aggregation, in the MunicipalityResidence table, of an additional
column with the name NewColumn, containing the value Table in its cells.
If we click on an empty area of any of these cells, the record obtained from
the ProvinceResidence table, the result of the crossing operation, will be
displayed at the bottom of the data area.
However, we have not yet transferred any data between the tables. Now that
we have established a relationship between them thanks to the Merge
Queries option, we must select what data from the ProvinceResidence table
we want to take to MunicipalityResidence; what we will achieve by
clicking on the icon next to the header of the NewColumn column, selecting
the Expand option (default) and checking only the box in the
ProvinceResidence column.
When you click OK, the selected action (Expand) expands the
ProvinceResidence table to which each cell in the NewColumn column
points, and as a result, brings the MunicipalityResidence a column with the
name NewColumn.ProvinceResidence containing the names of the
provinces.
After changing the name of the new column to ProvinceResidence, we will
move its position until it is located next to ProvinceResidenceID. We will
use the Move | Left, from the Any Column group, on the Transform menu
tab. We will have to execute this option a couple of times until the column
is placed in the desired position.
Place of residence. Creation of the code for bleached municipalities and
union of consultations
When generating the code of the place of residence in the PopulationCensus
table, we saw that for the municipalities with less than 10,000 inhabitants,
the municipality code is not provided due to data protection issues. This had
led us to decide to use the code 999 for such cases, which means that, for
example, for province 08 (Barcelona), the code of the place of residence
will be 08999.
The MunicipalityResidence table that we have just created would currently
lack all this set of records that we do know about the province, but we do
not know the municipality, and that is necessary for the measures that we
are going to implement in the modeling phase to correctly perform their
calculations. Then we explain a technique that will help us solve this
problem.
In the ProvinceResidence table, we will add two new columns:
MunicipalityResidenceID (Text) and MunicipalityResidence (Text),
containing respectively the code 999 and the literal Not available.
Next, we will position ourselves in the MunicipalityResidence table and
select the Append Queries menu option, from the Combine group, Home
tab. In the Append window, we will select the ProvinceResidence table, and
when you click OK, the records of the latter will be added to
MunicipalityResidence, completing the code combinations necessary for
this table.
I n the past two chapters ( chapter 5 - chapter 6 ), Query Editor was the
Power BI tool that completely occupied our attention, showing us how to
build the tables of a model from the functionalities of extraction,
transformation, and load (ETL) that it has.
Once the creation of the tables is finished, in this section we will continue
our task of developing the data model, using on this occasion the Power BI
designers most directly related to the Power Pivot engine: Data and
Relationships, responsible for the development of measures, hierarchies and
relationships between the tables of the model. We will also pass briefly
through the Designer Report, just to check the values of the measurements
generated in the data table.
Once the control is selected in the Visualizations panel, we will click on the
PopulationCensus table of the Fields panel to display its elements (fields,
measurements, hierarchies) and check the box of the Total Population
measure, which will automatically go to the Fields property of the control,
belonging to the section of the same name, within the Visualizations panel.
As a result, the control will display the measurement value using an
abbreviated numerical format.
To show the value of the measurement with the complete number format,
we will click on the Format section of the Visualizations pane, and within
the Data label section, we will change the value of the Display units
property from Auto to None.
I n the past, companies were stuck with tables, spreadsheets, and static
charts. Today, the use of joint and connector tools makes it possible to
use and generate data more intelligently. Flexibility and personalization of
data storage allow you to analyze and guide decisions in companies and
corporations.
Data pinned to offline spreadsheets does not allow correct and fast sharing.
We know that business data and information has increased. On the other
hand, the speed at which companies need to make decisions also increases.
Using the right tools for the data processing task increases the speed for
processing, manipulation, and understanding. Saving time is one of the
main benefits. Regardless of the area of business, corporations and new
businesses need to adopt more dynamic and powerful analytics tools.
Large, medium and small businesses must choose this path urgently.
Information cannot be lost and the company cannot waste time. Microsoft's
Power Bi program is critical to new endeavors.
All the best companies want to download and use this tool that connects and
expands access for the workforce. The tool has four elements and enables
you to turn a huge amount of data into optimized views.
This information can be absorbed and understood in moments. Being
dynamic, they adapt to any need, which improves the decision-making
process. The company will change its organizational and administrative
culture. We can say that this tool is the present and future of enterprise data
organization, allowing to overcome the old difficulties of the past.
Some companies may not see an advantage in being Microsoft, a very
traditional brand that has already launched outdated services like MSN and
Outlook, but the company has adopted a policy of launching more specific
products for different situations.
The company is updating itself in the market and strives to make significant
changes never before seen in the company. Following the launch of
innovative products, Power Bi is part of this new trend. The company
listened to end-users, and they identified what they thought was best and
did not develop the program based solely on what they understood.
We know the company is a leader in operating systems, personal and
corporate program development. After all, who has never used Office?
Despite its large portfolio, and being a superpower, the company needed to
innovate in other sectors, such as management and information
management.
Although new, Power Bi is inherited from SQL Server Analysis Services.
The SSAS team developed the foundation for the new software from Power
Pivot (the data modeling engine), one of Excel's first extensions. Most
current Microsoft software can integrate with this joint tool depending on
the skill of the user.
In this book, we seek to present the main features and applications of the
functions of this tool that has grown a lot in the data and information
management market. Data sharing and simplicity are the best reasons for
companies to invest in this tool that makes it possible to optimize data and
Excel connections.
Today, companies are looking for time savings, flexibility, and real-time
data refresh as a way to unify the efforts of businesses and corporations. It
is worth researching, installing, and studying this tool and its four interface
and application elements.
References
https://powerbi.microsoft.com/en-us/blog/
https://exceleratorbi.com.au/blog/
https://datachant.com/
https://www.academia.edu/36243555/Analyzing_Data_with_Power_BI.pdf
https://www.powerpivotpro.com/wp-
content/uploads/2015/10/PowerPivotPro-Reference-Card.pdf
https://yodalearning.com/tutorials/power-bi-dax-basics-power-bi-dax-
function-list/
http://www.powerpivot-info.com/public_files/cheat-sheet/powerpivot-dax-
functions-long.pdf
http://projanco.com/Library/The%20Definitive%20Guide%20to%20DAX-
Business%20intelligence%20with%20Microsoft%20Excel,%20SQL%20Se
rver%20Analysis%20Services,%20and%20Power%20BI.pdf
Power BI
Simple and Effective Strategies to Learn the
Functions of Power BI and Power Query
DANIEL JONES
Power BI:
A Disruptive Reporting Platform
Introduction to Power BI
Power BI is a cloud-based analytics service that provides a unified view of
the mission-critical business data. It’s Software as a Service (SaaS) offered
by Microsoft in the reporting and visualization domain. It offers three basics
components, which are:
Power BI ( Online Service)
Power BI Desktop
Power BI Mobile
Here you will see the basics of Power BI and a critical feature termed as
Natural Language Query. Before you understand each of these components
separately, let’s have a look at the Architecture of Power BI. The
architecture will explain how Power BI components are related to each
other. If not, I am here to throw more light on it. Let’s understand the
sequence as:
Create Reports using Power BI Desktop (On-Premise) : Power
BI desktop is a report authoring and designing tool that can be
installed on your machine. You can use this tool to connect to more
than 60 data sources and create a data model for further creating
your reports.
Publish Reports to Power BI online service (On-Cloud) : Once
you create the reports, you need to show it to the world. But how?
That’s where the Power BI online service comes into the picture.
The reports created using Power BI desktop can be published to
Power BI online ( https://powerbi.microsft.com ). For publishing the
reports, you need to sign in to the online service using your official
ID only.
Consumer Reports on various devices : Once published, the
reports can be shared with the world. The shared reports can be
viewed on desktop browsers and even through the Power BI Mobile
App.
Now, you have a fair idea about the Power BI architecture. Let us explore
the three Power BI components separately.
Power BI Desktop
Power BI Desktop is a report designing and authoring tool with advance
data shaping and modeling capabilities that helps you to get your data ready
for analysis in a short span of time.
Through Power BI Desktop, you can connect to more than 60 data sources
and then make a data model using the Query Editor. Once the data model is
built, you can develop your reports on it. After you create reports, you need
to share them with peers. There are two ways the reports can be shared.
One, the reports can be sent to peers in the form of a file with the extension
.pbix, which is the default file extension for Power BI project files.
Alternatively, you can publish your reports to Power BI online service and
then share it with your peers. For sharing online, all your peers must have
authorized access to the Power BI online service.
Power BI Mobile
Power BI mobile is a very useful and important part of Power BI. If you
want to keep track of your data while you're on the move, you can use one
of Power BI's mobile applications for iOS, Android, and Windows devices.
You can view all your reports, data, and all analytics on your mobile screen.
You need to install Power BI Mobile App on your mobile device or Tab.
Once the app is installed, you can log in to the app using the credentials that
you use for Power BI Online service. After logging in, the app takes you to
the dashboards that were created by you or shared by your peers. This way,
you are always connected to your business.
Power BI Mobile app allows you to set the alerts to notify you whenever
there is a data modification at the source of data. This app is suitable for
users who are always on the move.
You can open any of the dashboards by tapping on them. Within a
dashboard, you can tap on a dashboard tile to focus on it in a larger view, as
shown in the following figure.
You can also annotate any insights that you discover by tapping the
Annotate button in the top right corner. This allows you to draw on a
focused tile to highlight particular areas of interest. The annotation tools are
found along the bottom of the screen.
Share your annotated tile by tapping the Share link in the top right-hand
corner. Tap the Report link in the top right-hand corner to view the report
for a tile. This will display the same visualizations that you would see in a
web browser or Power BI Desktop. Also, it will include the ability to
interact with the report by tapping on bars, drilling down, or using slicers.
Please Note: The details/demonstration of Power BI Mobile is out of the
scope of this chapter.
Now you are aware of multiple components of Power BI and ready to move
on with more digging into details. However, we would like to stop here and
think about why we are calling Power BI as a disruptive reporting platform.
Yes, it is disruptive, and it’s challenging the other tools that are available in
the market. I would discuss a very significant feature of Power BI that is
making it different from others. This feature is called Q&A or Natural
Language Query.
Benefits of Power BI
1. Accessibility: Data is more accessible in Power BI. Power BI can
connect to a huge number of Microsoft as well as non-Microsoft
solutions.
2. Implementation: It’s very easy to implement power BI.
3. Robust access control and Security: Row Level Security is the
feature of Power BI, which makes it different than others. It allows
a team to grant and rescind access on a very controlled level.
4. Drag and Drop functionality: Through familiar drag and drop
functionality, an end-user can create his/her own report easily—
Drill Down Functionality.
Import and Manage Data Sources in Power BI Desktop
Here you will understand the various ways to manage your data sources in
your Power BI desktop. Let’s go through the steps to import a data source
first.
Import Data Source to Power BI Desktop
To Import a data source into your Power BI Desktop, follow the below
steps:
1. From the ‘Home’ ribbon, select ‘Get data’ or click on the down arrow
next to ‘Get Data.’
2. The drop Down will show some frequently used data sources along with
an option ‘More’ at the bottom.
3. Click on the ‘More’ will give the ‘Get Data’ menu. The ‘Get data’
menu can be brought up by clicking on the ‘Get Data’ button in the
Home ribbon.
4. The data sources have been categorized, as shown in the left pane of the
above snapshot.
5. The required data source can be selected just by selecting the proper
category and data source name. The data source ‘Oracle database’ has
been selected which comes under ‘Database.’
6. By selecting the button ‘Connect,’ a pop up will appear, which will
have a label where the Server name to be put.
7. After putting the server name / global database name as per the above
snapshot, the window will appear once ‘ok’ is clicked.
8. Put the credentials in the Username and Password boxes as shown
above and click ‘Connect.’ Once the data source is connected, a
window will appear where you need to select the required table/tables.
9. After selecting the required tables, click on the ‘Load’ button.
Introduction
Here you will see the information about Power Bi architecture and how to
create, publish, and schedule a Power BI dashboard, how to create
parameters, and also limitations of Power BI.
Power BI Architecture
Data Sources: In power BI data sources can be broadly classified into two
types cloud data sources and On-premise data sources.
Cloud data sources: Azure SQL Database, Azure SQL Data
Warehouse, Azure Blob Storage, Excel files in OneDrive, Online
Services as Facebook, Mail Chimp, Salesforce, Google Analytics.
On-Premise Data sources: premise data sources can be further
classified into two types as On-premise databases and On-premise
files.
On-premise databases: Oracle, My SQL, Teradata, SAP HANA, SQL
Server Analysis Services(SSAS), Sybase, IBM DB2.
On-premise files: Excel, CSV, XML, Text files.
Power BI Authoring PC: This authoring machine should have two
components installed they are:
Power BI Desktop: It is a windows application which can be
downloaded from Microsoft’s Power BI portal. By using this
application, you can design interactive reports and dashboards.
Report files can be saved on local disk with .pbix extension. The
reports and datasets can be shared in the Power BI portal.
Power BI Personal Gateway: Needs to be installed separately on
authoring PC along with Power BI Desktop and is a bridge
providing quick and secure transfer of data in between the Power BI
portal and on-premises data sources. Available only with Power BI
Pro Subscription. Azure Service Bus provides security for the data
transferred between the gateway and the Power Bi Portal, providing
a secure channel between your computer and the Power Bi service.
This secure channel means that there is no need for you to open any
ports in the computer firewall.
Power BI Portal: It is where users publish their datasets and reports, create
dashboards and content packs, and share data with team members of their
organization. Users can sign in to the portal using their organization
account. Each user will have a personal workspace in the portal named My
Workspace, which comprises dashboards, reports, and datasets published by
the user.
End Users: Dashboards can be shared via email with multiple stakeholders.
Power BI offers a free mobile app for IOS, Android, and Windows devices.
Reports and dashboards automatically adjust their sizes to fit the screen of
the device, so users need not worry about creating mobile versions of the
work. Users can interact with reports and dashboards through filters, slicers,
drilling, etc.
This creates treemaps that show the sales made through the internet and
reseller in various product categories.
Requirement 4: Locate countries and their respective sales on a
geographical map.
Steps to Create a Map Visualization
To fulfill this requirement, map visualization can be used.
Select Map from Visualization pane.
To enable the drill-down feature on Map drag and
drop SalesTerritoryGroup and SalesTerritoryCountry columns
from the DimSalesTerritory table in the location section of Fields
pane.
In the size section, drag the measure TotalSalesbyDAX.
Formatting can be done by changing the bubble colors using the
data color option and increase the bubble size by using the bubble
option.
As the drill-down feature is enabled from SalesTerritoryGroup>
SalesTerritoryCountry. On drilling down, European sales made by
the individual country in Europe can be seen.
Requirement 5: Create a filter on the sales territory group.
CREATE OR REPLACE
PACKAGE BODY customer as
FUNCTION Fn_customer (p_gender string default null) RETURN
customer_type pipelined AS
v_c_tr_type customer_type;
v_count PLS_INTEGER := 0;
BEGIN
FOR r IN c_tr_customer(p_gender)
LOOP
v_c_tr_type := customer_type(r);
PIPE ROW(r);
v_count := v_count + 1;
END LOOP;
RETURN ;
END Fn_customer;
END customer;
/
When package function is called by passing ‘M’ as input, male
customer details were shown as output.
Click on get data in Power BI go to databases select oracle database
and click on connect. Give the server name and write the query in
the SQL statement.
‘M’ is passed as input male customer details will be loaded.
This is how you can call oracle packages in power BI.
Limitations in Power BI
In Power BI, the size of the table does not increase or decrease
relatively along with the data, and when data is more scroll bar
should be used to scroll down, and when the data is less, the empty
space will pop up in the table .
.Pbit file can’t be uploaded in the Power BI portal you can only
upload .Pbix files where the .Pbit file prompts for a parameter so
you cannot upload reports with parameters in the portal.
There is no visibility property in Power BI, like in SSRS, to hide the
visualization depending on the condition given.
Conditional formatting can’t be applied to fields when the data type
is other than integers. The conditional formatting pane has only
employee key, so conditional formatting can be applied only in
numerical fields.
Dashboards and reports can only be shared with users who have the
same email domains or email domains listed with Office 365 tenant.
Microsoft Power BI is still in the early days. The tool will be getting
updates every month by considering the requests from the users.
Scheduling of reports in power BI portal is not as flexible as
Scheduling SSRS reports using share point.
Power BI Desktop
Functionalities
In this chapter, you will understand the basic and detailed concepts of
Power BI Desktop implementation with clear examples. Also, you will see
the advantage of Power BI Desktop in data visualization.
1. Load the table data with hardcoded parameter value into Power BI
desktop.
2. Data Loaded into the Power BI Desktop with dataset name
‘Query1’.
Create Parameters
Add Parameters in the Power BI desktop to pass the dynamic parameter
value while loading the data into Power BI Desktop.
1. Right-click on the ‘Query1’ and select the ‘Edit Query’ option.
2. Select Manage Parameter drop-down and click on the ‘New
Parameter’ option.
Now, create two Parameter with the names “Year” and “Workweek.”
Year Parameter Creation.
WorkWeek Parameter Creation.
After the creation of two parameters, click on the “Close & Apply” option
to save.
Assigning Parameter Values Dynamically
Change the hardcoded Parameter values to the created Parameter names to
get only the specific data loaded into Power BI Desktop based on the I/P
Parameters.
1. Right-click on the ‘Query1’ and select the ‘Edit Query’ option.
2. Click on the drop-down arrow nearby Query Settings.
3. You will get the hardcoded value for YearName and Week.
4. Now try to replace the hardcoded values with the created
parameters (Year & WorkWeek). The tick mark(Parse) will tell you
whether your modified query is correct or not.
5. For better understanding, you can rename the ‘Query1’ dataset to
whichever name you want. “MissedRecords table loaded into PBI
with dynamic parameters.”
6. You need to follow the same procedure which you did for the 1 st
table dataset ”MissedRecord” to load the 2 nd table “Missed
Percentage” by passing the dynamically created parameter values.
7. For the 3 rd table, I don’t want to pass any parameters; instead, I
want to load all the data. Creating visualization for the Loaded
DataSet. Select whichever objects needed from the visualization
menu.
8. Select whichever data fields which you want the user to see in the
Power BI Report.
9. I have pulled data fields from two Dataset “MissedRecords” &
MissedPercentage” and created a tabular view of data.
Once you have completed the above steps, you can start the below ones.
1. For formatting the text and good design, click on the red circle
highlighted to see the available formatting option to alter the text
format and design format.
2. You can also change the Data Type of any attribute, for example,
click on the Missed_Record field and click on the Modeling menu
to change the data type.
3. Create a new tab to create the Missed records Trend using
Visualization in PBI.
4. As I told before, I haven’t set up any dynamic parameter value for
this Dataset MissedTrendData. Then pull all the data from this table
from SQL DB.
5. Copy the created design and paste on the same tab.
6. Click on the pasted design and select the Line graph, then your
design will change. Click on the yellow color highlighted option to
change the level of data to the lowest with an ordered format.
7. Change the Y-axis scale type to ‘Log’ to arrange the data in proper
order. Enable the ‘Data Label’ Option to see the values for the
corresponding Year & Work Week.
8. You can filter the data by using the slicer tool ‘Year Name,’ then the
report will also reflect based on the selected value. Save and close
the Power BI desktop .
9. Reopen the Power BI Desktop; it will ask for the parameter values.
Now, data got loaded, and you can see the same tabs.
1 st Tab - You set dynamic parameter values for the two datasets
“MissedRecords” & “MissedPercentage.”
2 nd Tab - You loaded the “MissedTrend Data” dataset without
setting up any dynamic parameters.
For testing purposes, I have pulled Week, and YearName attributes from the
loaded “MissedRecords” dataset to verify the data loaded only for the
selected Parameters.
Publishing Power BI Desktop to the Web (Power BI Service)
1. Click on the Publish tool.
2. Sign in to Power BI Login.
3. Select Destination place where to save the Power BI report.
4. Once the above step is done, you will receive a link to your report.
5. Click on the link to open the report in your Power BI publishing
site.
Minimum System Requirements to Run Power BI Desktop
Windows 7 / Windows Server 2008 R2, or later.
.NET Framework 4.5 or later.
Introduction
This chapter provides details about the process required to implement Real-
Time Dashboards using the Power BI Preview feature of Office 365. It
describes best practices for building a business intelligence (BI)
environment by using a combination of Microsoft Power BI, Microsoft
Office 365(O365), and on-premises data sources.
This chapter will help you understand designing and sharing a real-time
dashboard. It will make you aware of its functionalities and benefits as well.
It also provides you with information about how you can connect to various
data sources to fetch your data and use the same for building your
dashboards.
To start with, you should have the data, or Power BI reports that will help to
build your dashboard in some data sources like Excel Workbook, SSAS,
GitHub, etc. You should also have some basic knowledge on how to create
Power BI reports, though it is not mandatory. It will help you to learn how
to create Power BI reports and will help you to create real-time dashboards
having tiles made of visualization (like charts, map, combo charts, graphs,
etc.)
Power BI Preview
Microsoft Power BI dashboard helps you to stay up to date with the
information that is important to you. Your dashboards have tiles that lead to
the reports which you can explore on just a single click. You can bring all
your relevant data together in one place by connecting to multiple datasets.
Reasons for Creating the Dashboards
To see all the information needed to make decisions in one place and
one look.
To increase efficiency and support the decisions based on the most
important facts.
To ensure all the colleague's views and use the same information.
To help the business determine goals and strategies and monitor the
health of a business.
To allow you to identify and correct negative trends using metrics
and trends that matter a lot for business.
When you first open Power BI Preview, you'll see:
Navigation pane
Dashboard with tiles
Q&A question box
Help and feedback buttons
Dashboard title
Home button
Version
Navigation Pane
The three objects of Power BI Preview include dashboards, datasets, and
reports. You can use the Navigation pane to explore them. You can have no
data in dashboards and reports, but that is not useful until you have the data
with you. So for creating dashboards, you need to have data.
Datasets
You need to have data for dashboards, and for getting that, you can use
datasets to connect to various data sources. After gathering all your data in
one place, you can start by creating reports or dashboards. You can even
bring your already created reports using datasets .
In the navigation pane, you can find all the datasets that you have connected
to present in the heading Datasets. Each dataset listed is only having a
single data source. Let’s say that you have an Excel sheet in OneDrive, your
computer, or any of your on-premises datasets, Salesforce database, etc.
ONE dataset is useful in creating many reports, or you can say the same
dataset is used many times in different reports. You can pin as many
visualizations from your dataset to any number of the dashboard.
To connect to a Dataset, you can either click GetData from the top of
Navigation Pane or Click on next to Datasets.
In some cases,
When Power BI Preview imports a copy of the dataset, then, in that
case, the changes you make won’t affect your original dataset since
it is a copy of your dataset.
When Power BI Preview connects to your dataset like if the
workbook was imported from OneDrive for Business, then you can
refresh your dataset with the latest data from the workbook on
OneDrive.
Dashboards
A dashboard is a visualization tool that shows you the current status of
metrics, graphs, charts, KPI’s, etc. related to business on a single screen for
an enterprise. It is created by the co-workers and shared with the concerned
members in an organization to stay up to date. Dashboards consolidate tiles.
Each tile contains visualization created from the underlying data in your
datasets.
You can find your dashboard listed in Navigation Pane under Dashboards
heading.
ONE dashboard can show visualizations from many different datasets, and
the same goes for reports as well. After creating a dashboard, you can share
it within your team as well.
You can even import your dashboards from other SAAS services with the
dataset like the Get Data popup for Salesforce has an option of getting
dashboard and/or report to be created from your dataset.
Reports
The Power BI Preview report contains page(s) of visualizations. You can
create reports from scratch using the PowerBI Preview itself, or you can
also import them using datasets. Once you add a dataset, it automatically
gets added under the reports heading in Navigation Pane, but only if your
data is formatted properly, and it has visualization in Power View sheets
and with shared dashboards. For example, if you are connecting to the
Microsoft Excel workbook, which has the Power View sheets present in it,
then the Power BI Preview will automatically create a new report as per the
visualization present in those sheets. You can even create Reports based on
the data you have using Excel tool-kit like Power Query (Discover and
Connects to data), Power Pivot (Transform and models data), Power View
(Create Visualization (charts & graphs))
You can find your reports in the navigation pane listed under the Reports
heading. Each listed report has a page(s) of visualization. You have two
ways to view as well as interact with reports. They are:
Reading View: There is no need to worry using this view as you cannot
modify or update anything. All you can do is explore and browse the data
and visualization in the report, and temporarily pin any of the visualizations
you want in your dashboard. (The filters applied while interacting with your
reports also won’t be saved, and neither the pinned tiles will be saved when
you close and reopen Power BI Preview).
NOTE: To edit the report and save your changes, you have to open it in
Editing View.
Editing View: As compared to Reading View, In editing View, you can look
into your data by creating new visualizations, changing visualization type,
adding and deleting visualizations, adding and removing fields, and adding
pages from the report.
NOTE: To edit a report, you must be the owner of the report
NOTE: If a dashboard has been shared with you, then you won’t be able to
see the report in the navigation pane. You will be able to open the report
only if the report owner pinned that particular tile from the reports or
otherwise if the owner created from the Q&A, then the Q&A page opens.
ONE report can be used in multiple dashboards. Tiles selected from the
different reports can appear on the same dashboard. ONE report can be
created from only one dataset. There is an exception to this - you can use
Power BI Designer, which is capable of combining more than one dataset,
to build a report. There is also an option in GetData ‘Power BI Designer
File’ to import a copy of it and build your dashboard.
Dashboard Tiles
Dashboards are made up of tiles containing visualization. They are created
either in report Editing View or Q&A. The owner of the report pins the
tiles that appear on a dashboard.
You have now created the dashboard.
Benefits
Shows the holistic summary view for all the metrics in the current
fiscal year.
Real-time status of Product Launches launched and Hot-fix
information.
Single view to show everything that’s needed for the business.
Information on Dashboard
Product Launches: The Product Launches metrics show the Standard
Product Launches count and the Non-Standard Product Launches, count.
Quality: The Quality metrics will show the data for both Production defects
and Hot-Fixes. The Fields shown under this category are below:
No. of Production Defects
Standard Defects & Non-Standard Defects
Bad Hot-Fixes & Good Hot-Fixes
Drill-down views: Drilldown views for each of the categories are shown in
the report.
Product Launches Drilldown: You can show the Product Launches
in different dimensions. Product Launches against Business Groups,
Product launches against Launch lead, and Product Launches
against Functional Areas.
Quality Drilldown: You are showing the quality metrics in multiple
dimensions based on the need. You can show the defects against the
functional Area, Defects against launch type, and Defects against
the environment—Hot-Fixes against good or Bad Hot-fixes,
hotfixes.
Home Button
To return to your dashboard, click on the home button that appears on the
top left corner of all screens in Power BI Preview. You may also return to
the navigation pane using this button.
The Retail Analysis Sample Dashboard
The first time you visit https://app.powerbi.com to open Power BI Preview,
you will find a sample dashboard, i.e., Retail Analysis Sample . Unless
you manually remove this sample, it will always be there. You will not see
any reports under Reports heading even if the sample dashboard because of
the earlier mentioned reason that it is shared with you. You will only be able
to view the report through tiles if the owner pinned the visualization from
the report. You can explore and learn from this sample until you remove it.
Select the workbook that you need and click the Connect button. When you
are done connecting, you are ready to start.
You can create visualizations like charts, graphs, a Filled Map, TreeMap,
Funnel, Gauge, Cards, Combo Charts, etc. You can explore and learn from
your own.
Now select the visualization you want
Once the dashboard is saved, to see the workbook that you uploaded under
the Dashboard heading, you can return to the main Power BI Dashboard
pane.
The Power BI Q&A and connection to your workbook you uploaded into
your dashboard will appear when your dashboard opens.
Introduction
Power BI can be used to build reports adhering to the business
requirements. With Power BI, user can:
Connect to a variety of data sources.
Can bring in the data from these sources and transform the data
which matches the requirement or prep it for further analysis using
tools like Power Pivot or Power view.
Create custom views over the transformed data.
Perform data cleansing/modelling/integration operations.
Data can be imported from multiple log files.
Create a visualization of data using numerous graphical designs that
are already available.
You will mainly focus on connecting to the SQL database, generating
required reports along with visualizations and mailing of reports to specific
groups or individuals.
Setup
Power BI can be downloaded from the following link Power BI download .
The link also has other requirements that specify the software requirements
for installation.
1. After installation, the Power BI Desktop icon appears on the
desktop.
2. Sign in needs to be done.
3. Power BI account needs to be created if not already present.
4. After providing the correct credentials, sign-in is successful.
Getting Started with Power BI
You will consider the SQL database as your source.
There are mainly six parts to it –
Connect to the database
Data Load
Data Refresh
Report Generation using visualization
Publishing the report
Subscription and mailing of the report.
Connect to the database
Click on the ‘Get Data’ tab and a pop up showing all the data sources come
up.
Click on the ‘Database’ option, choose the SQL Server database, and click
on connect.
Provide the required SERVER (SID/database name) and QUERY in the
highlighted text box.
Then provide the credentials of the database you want to connect in the
highlighted text box.
Data Load
The user can see the data in a popup and load the data into the desired
window.
Data Refresh
Then change the source to some other environment and edit the permissions
by giving the credentials.
Steps to Follow
1. If you have a data column to pull data from, then create two
columns, Month and Month Name directly in Power-BI. To get
options to pull Month and Name, you must select the date column
and then click on add column tab. These operations must perform
on “Edit Queries Edit Queries.”
2. Once you created new columns with the name “Month” and “Month
Name,” replace the “Month” column name with “Month Number”
and “Month Name” with “Month.” And close edit queries window
and apply changes.
3. Create a filtered chart for testing and add a Month column for
filtering the data.
4. Now, select the Month column from rightmost columns and select
Sorting by column as “Month Number.” This operation performs
the sorting of month column based on month number.
5. After updating the sorting, the filter chart that you created earlier
represents data in the way months come.
Showing Data in a Geographical Way
If your data is having geographical information like country, latitude, and
longitude, then a chart can be displayed with few clicks to show
information based on geographical location.
Steps to Follow
Steps to Follow
Introduction to Power BI
Power BI is self-service business intelligence. It provides highly interactive
visualizations, where a user can create reports and dashboards by
themselves. It has an interface that is very much similar to Microsoft Excel
but is more powerful in terms of reporting and dashboards.
It provides a cloud-based Services –known as Power Bi Services, along
with Power BI Desktop interface. The Initial version was unveiled in
September 2014.
Power BI service provides fast and easy access to data, supporting inputs
from most of the data sources, and the data can be visualized and analyzed
by anyone.
Here we will discuss points to publish a Power BI report to Power Bi online
dashboard with Row-level security and how to embed this report to the
SharePoint site. This is an open-source Power BI Desktop and Power BI
Service online to allow to build simple to complex report to monitor the
health of the system. You can provide different facilities for the end-users to
visualize the data.
Benefits of Power BI
1. Fast Deployment, secure, and can be integrated with any existing
systems.
2. Pre Build Dashboard templates.
3. Supports both live connections, on-premise, and cloud.
Dynamic Row Level Security
Power BI automatically updates the data in real-time and providing options
to refresh the data by schedule refresh promptly and which will depend on
data sources that you are binding to the Power BI report. Real-time data
options will be available through Azure Stream Analytics, integration, and
the REST API for Power BI. With both mentioned ways, the data can be
moved into Power BI directly.
Power BI Desktop
Power BI desktop is a visual data exploration and reporting too. Using this
reporting tool, users can connect diffident data sources and can generate
reports and dashboards as a single location. Power BI desktop tool can
connect a variety of data sources like Excel, SQL, OData feed, etc. There
are already many supporting formats like charts, table which can help the
user in analyzing the data.
Power BI desktop can connect different data sources like with file (Excel
and CSV), Azure (Azure Services), Databases (SQL, and Oracle Server
DB), and also Facebook and Google analytics.
To restrict data at report or dataset level, Row Level Security (RLS) is used.
To implement dynamic RLS in Power BI, you need to follow the below
steps.
1. Create a role and maintain security logic (using DAX Expression)
in the Power BI Desktop tool.
2. Create a workspace & members to it for whom RLS has to be
enabled (Optional)
3. Upload the report to Power BI services and assign users under the
security tab of the dataset.
Here you will use the data from an Excel source, which has two tables,
Sales_Products, and Country.
Sales_Product Table
Country Table
In this example, you have three users Mary (Manager of US & Canada),
Dan (Manager of UK) and John (Admin User)
You will create a report and apply dynamic security. The Manager will be
seeing only those countries which belong to him (or) her.
Steps to Implement Dynamic RLS
Import tables in Power BI and create the relationship by joining the
“Retailer_country” column from the country table with the “Retailer
country” column in Sales_Products.
This relationship is associated with the Manager Id.
Step 2 :
Create an app workspace in Power BI service as Implement_RLS_Group
and add the members into it.
Log into Power BI services (using admin login), click on “Create app
workspace” under workspaces.
Then provide Name, Privacy settings, and members mentioned as below
example.
Example:
Name: Implement_RLS_Group
Members:
[email protected]– Admin (The person who creates the app workspace)
[email protected] – Member (Manager for the UK)
[email protected] – Member (Manager for US & Canada)
Step 3:
Assign users to Power BI Security.
First, save, and then publish the report under “Implement_RLS_Group” in
Power BI. Then, navigate to the “Security” tab of the dataset, which has
been published just now (In your case, the name of the dataset is
Store_RLS).
Click on the “security tab,” you will see the role you created in power BI
Desktop. Add the user under that role for whom RLS should be
implemented.
The users added on this page will see only those records, i.e., which are
associated with their own username. Whereas for the user who publishes
(admin), the report can see whole revenue details since he/she is the admin.
Step 4 :
Test the RLS by logging into BI services using Mary or John login.
You should only see those records that belong to them.
This is how Dynamic RLS is implemented in Power BI.
Simple Row Level Security in Power BI
Power BI Row-level security can be used to limit the report access for
specified users. Also, you have Power BI filters to restrict data at the row-
level; the filters within the roles can be defined.
The security roles can be defined by following these steps:
1. Open the Power BI report and select the Modeling tab.
2. Then choose Manage Roles option from the Modeling tab.
3. Select Create .
4. You should name the role after clicking on the create button as
above.
5. Choose the table in which you are going to restrict and choose a
DAX rule to apply.
6. Enter a DAX expressions - this will return true/false. E.g.: [Entity ID]
= “Value”.
7. You can select the checkmark after applying the DAX formula to
validate above the expression content box to the expression as below.
8. Choose Save .
Users can only be assigned roles through the Power BI service, not
through the Power BI desktop. However, the Desktop can be used for
creating the role.
9. After creating a role, the results of that role can be validated in Power
BI Desktop. For this, you should choose View As Roles option from
the Modeling tab as below shown below.
10. You can see and change the view roles using View as Roles dialog
as below.
11. After that, you can select the checkbox for the respective role you
have created and click on OK to apply modifications. The reports
will pull the data appropriate for that selected role only. You can
select other given user checkbox also.
You can bring the data from the below datasets to Power BI.
1. SaaS Data Sources (Software as Service): GitHub, Microsoft
Dynamics CRM, SendGrid
2. Azure Resident Systems: Azure SQL/DW
3. On-Premise systems: SQL, Tabular, Excel, PBI Desktop
Row-Level Security in Power BI
You have to create roles within the Power BI Desktop. You cannot create
the roles in the Power BI service.
When you publish this to Power BI Service, the role definition will also be
published. You can add the users in the Roles created at Power BI Service.
From the above web source, I have selected the data from Table(0).
Step 2:
Now select the Modeling tab and click on the Manage Roles.
I’m creating a Role Texas to enable the user to view data only in that State.
You have to create the DAX expression for the same and can validate by
clicking on the tick mark to avoid further errors.
As mentioned above, you cannot assign users within Power BI Desktop;
this can be done only at Power BI Service.
Instead, you can have dynamic security in Power BI Desktop using the
username() and lookup function as in Tabular Cube.
Step 3:
Publish this report and log onto the Power BI Service. Under the datasets,
click(…) on the Model that you have created.
Now you can add the User ID under the members of the Roles created. You
can also test the Role by clicking on Test as Role. (Now you will be able to
see the data only for Texas).
Publishing the Report
1. Select the Publish button.
2. Once Publish has done, it will show below popup for
success confirmation.
3. By using the Link in the above popup, you can open Power
BI online service.
4.
Manage Security on Model
To manage security on your data model, you should do the following steps:
1. Select the security under the dataset .
2. You can add a member to the role by giving an email address or
name of the user. This member should exist within your
organization. You cannot add Groups created within the Power BI
desktop.
3. You can remove members also by clicking on X next to their
names.
Introduction
In this chapter, we will discuss the Bookmarks in Power Bi Desktop, how to
implement the Toggle button with the Bookmark feature, and how to
implement report Tooltip in Power BI desktop.
Click on three dots you will get the options of the bookmark, then
select rename and type Tables.
Add another bookmark and rename it as Visualizations.
Select the Tables to configure tables bookmark.
Configure the tables bookmark.
Select tables, then in the selection pane, click on the eye button
to hide the visuals of graphical visualizations and toggle button
images.
Click on three dots then select an update to update the
bookmark.
Configure the visualizations bookmark.
Select visualizations, then in the selection pane, click on the eye
button to hide the visuals of tables and toggle button images.
Click on three dots then click on Update to update the bookmark.
Configure the Tables Toggle Button.
Select the Toggle button image, turn the Action slider to On, in
the format image section, then select type as a bookmark, and
select bookmark as Visualizations
Configure the Visualizations Toggle Button.
Select the Toggle button image, turn the Action slider to On, in
the format image section, then select type as a bookmark, and
select bookmark as Tables.
Arrange both the toggle button images one under another to feel like
toggle button in the dashboard.
Click on show all in the selection pane.
After the arrangement of images, the toggle button shown in
the below image.
While clicking the toggle button, press the Control key in Power BI
Desktop; there is no need to press the control key while clicking the
toggle button in Power BI Online Services.
When you click on the below button, you will get the tables.
When you click on the below button, you will get the
visualizations.
App Workspace
Apps Workspace will act as a placeholder for published dashboards and
reports. Apps are bound to App Workspace; that is, before you create an
app, you have to have an app workspace. App Workspace is fairly similar to
a group workspace.
The App workspace has dashboards, reports, datasets, excels.
Apps are the published version of whatever is inside of the
workspace.
Apps Workspace acts as a Potential Staging Environment for the
apps.
With Potential Staging Environment, we mean that you can modify
the dashboards, and then the dashboards can be published to apps.
After the apps are published, you can still make modifications to the
existing dashboards in the apps workspace and can publish the
updated app.
You can manage the users as to who can view the apps.
Creating Apps
Apps are a collection of reports dashboards and which are sent
across to multiple organizations or a group of people or even to
specific people.
Earlier Organizational content Packs were being used for
publishing. However, now Apps have replaced them.
As you create the app in the apps workspace, you grant permissions
on the dashboards.
Step 1: To Create the App Workspace, click on Create app workspace.
Step 2: Fill in the details for creating the apps workspace. You can add
members to this workspace.
Private: Only approved members of the workspace can view the app.
Public: All members of the organization can view the app.
Members can be granted permission:
1. View: Members can only view Power BI Content
2. Edit: Members can edit Power BI Content
Step 3: Go to your Power BI Desktop Version and publish the report to
Power BI Service.
Step 4: Select the destination to be published to:
Visit the report published by Power BI desktop in the Power BI Service and
pin this report to the dashboard.
Publishing App
Publishing App
Advantages
Rework in creating the data model is reduced.
If multiple reports are using a common dataset, then this is one of
the efficient approaches.
Refreshing the data for source. pbix file is sufficient; refreshed data
will be available in the new reports as well. This eliminates data
extraction from the same data set multiple times.
Limitations
Source. pbix file, which is to be used, must be published in the
workspace; any local files cannot be used as a source for a new. pbix
file.
Any changes made in the source. pbix file will be replicated in the
new files too.
If the source. pbix file is deleted in the workspace; the new file will
no longer work.
Power BI
and Share Point
Introduction
This chapter gives a brief introduction on using Power BI Desktop to
generate reports and dashboards and integrating the reports in SharePoint to
achieve Business Intelligence.
Business Intelligence in SharePoint is vast and is achieved with the
combination of SharePoint and Microsoft Power BI in particularly Excel.
This combination of the PBIX file and SharePoint enables us to create
dashboards, reports, and scorecards with simple as well as complex data.
The above-said process is two-fold.
Creation of Power BI Desktop file
Integration with the SharePoint
Power BI is a cloud-based Analytics Service that allows users to analyze
and visualize data with greater speed and efficiency. The data is
transformed into interactive reports, dashboards, or Compelling
visualizations.
The Power BI Service is built upon Azure. The Power BI service
architecture consists of 2 clusters.
1. WFE Cluster
2. Back end Cluster
WFE Cluster manages the initial connection and authentications process.
Whereas BE Cluster handles the user interactions. Power BI uses Azure
Active directory for the purpose of user validation & authentication,
whereas Azure Blob and Azure SQL manage the storage of data and
Metadata.
Power BI Service is not available as a private internal cloud. However,
using Power BI and Power BI Desktop, you can connect to your on-
premises data sources using on-premises Data Gateway.
Power BI is a Microsoft product which is of twofold:
Power BI downloadable Desktop program
Cloud service (online program).
This document elaborates the steps to install and create Power BI Reports
using Power BI Desktop program
Power BI Desktop
Power BI Desktop integrates the powerful query engine with the online
Power BI Service. It is a Powerful analytics tool designed for windows.
Powerful data connections, models, and reports are created using the Power
BI Desktop. Whereas Power BI Service is used to shares the power BI
Desktop reports to the users to view and interact with them
It is a powerful and highly accessible tool to build robust models and craft
reports.
How Power BI Desktop Works
Power BI Desktop enables the user to connect to different data sources data,
shape or refine the data and represent the data model in the form of reports.
This centralizes the scattered and disconnected data and represents them in
the form of reports. The user can save the work to a file, which is Power BI
Desktop file format (.pbix) file format. This can be shared with other users
by uploading the file to the Power BI SERVICE
Power BI Desktop Installation
Go to PowerBI.Microsoft.com and click on Products and click on Power BI
Desktop. Click on the download button. A PBI Desktop MSI file will be
downloaded to the computer.
Execute the MSI file by following the instructions. A shortcut icon will be
created on the desktop.
Requirements /Limitations
To use the Power BI, few requirements need to be satisfied.
1. Power BI Account – The user has to register to PowerBI.COM and
get created the account
2. Power pivots and power queries are used to generate reports.
3. A website is needed to upload the report. Website can be either
SharePoint / WordPress / any website / web page.
Power BI Report Creation
To start up with, double click the Desktop icon, a welcome screen is
displayed.
Click on Get Data Icon to select the raw input data. It supports many input
data formats like files, Databases, Azure, or Online services.
In this current context, you will take up the SQL Server database as input
data. Select the SQL Server database and click on the connect button. Enter
the database details.
Click on the Load button to load the data to Report.
Build Report s
The Report View has five sections.
The ribbon panel displays the tasks associated with the report.
Report View pane enables the user to view the Visualizations and
customize the report.
Pages pane enables you to add a report page.
Visualizations pane to customize the report like applying the
different kinds of charts and axis fields and filters.
Fields pane enables the user to drag query elements and filters to the
report view.
In this context, as the Power BI Table data contains state data, let us create a
Map report. Based on the input data and requirement of the user can create
different types of visualizations like Pie chart, Bar diagram, Line chart, etc.
To create the visualization, Drag and drop the fields column to the location
field, i.e., drag the state column to the report view, A map with the states
defined in the table.
In this example, as you created the selected Map Report Chart in the
visualization, the data available in the table column state is mapped to the
Map control Chart. An in-depth view of the states can be obtained by
applying filters for the states.
Step 3 - Sharing
You can share the chart with your organization or a particular set of people
or use it in the application.
1. Share the Report via Dashboard
a. In the web version Power BI page, you can find
“Dashboard” in the left panel. Click on + plus sign near
Dashboard.
b. In the left panel under “Report,” click on the report
which you want to share. Select the “Pin Live” page.
c. In the Pine Live page, select the Dashboard where you
want to share and finally click on “Pin Live.”
Introduction
Almost all of the testing projects require data to be tested/analyzed based on
the requirement. Many of the testing applications require the testers to set
up data, whether it might be simple or complex. This document helps to
understand how a user can easily get different data Sources for Data
Preparation/ Test data, modify the data as per the user’s needs (like
removing a column, changing a datatype, or splitting a single column) and
for Data analysis.
Power queries can act as an ETL tool and also can be used to build reports
adhering to the business requirements. It is a part of the larger domain
provided by Microsoft, i.e., Power BI. A power Query is a user-friendly
way to play with the data. Power Query is a free Excel add-in that allows
the user to import data into excel from many data sources, allow data
modification, refine data, and load to the data model. This applies to Excel
2016, Excel 2013, and Excel 2010.
With Power Query, user can:
Connect to a variety of data sources.
Can bring in the data from these sources and transform the data
which matches the requirement or prep it for further analysis using
tools like Power Pivot or Power view.
Create custom views over the transformed data.
Perform data cleansing/modelling/integration operations.
Data can be imported from multiple log files.
This section will mainly focus on connecting to the ORACLE database and
generating excel reports.
4. After doing the above steps, there will be a new Power Query tab
present in MS Excel, as shown in the below image.
Data Refresh
Right-click on the workbook query and click EDIT.
A Query Editor window pops up. Click on the Data Source settings tab.
Then change the source to some other environment and edit the permissions
by giving the credentials.
After successfully providing the credentials and connecting to the database,
refresh the preview and then close the query editor and load the data to the
main sheet.
The user can also refresh the data from a link button present in the
workbook query window tab (right side of the screen near the black arrow).
Simple Installation
Excel 2016 - Power Query is a built-in tab in Excel 2016. It has
been renamed to the Data tab. It is known as “Get & Transform” in
Excel 2016.
Excel 2010 & 2013 – Power query has to be downloaded from the
below link and installed.
http://www.microsoft.com/en-us/download/details.aspx?id=39379
Once the installation is completed, open excel, and the user will be able to
access the Power Query tab.
Incase power query tab is missing, follow the below steps:
1) Go to File > Options > Add-in.
2) Select COM Add-ins from the Manage drop-down.
3) Click the Go button.
4) Check Microsoft Power Query for Excel checkbox and Click on
OK.
5) Now power query tab will appear on the screen.
ETL Process
ETL (Extract, Transform, and Load) is a process where data is extracted
from various data sources and transformed in a proper format for analysis
and querying and loaded into the destination.
Extract
Data Sources
Power query can transform both structured and unstructured data from
various sources. Different sources include Excel, Web Page, XML file, Text
File, Folder, HDFS, Facebook, and from different databases such as SQL,
Oracle, DB2, MySQL, Sybase, Teradata, etc.
If you want to import data from the web, you need to enter the URL in the
textbox, so that the user is navigated to the desired web page.
The contents will be loaded in the form of tables on the extreme right of the
sheet under the Navigator section. If you hover over the tables specified
under the navigator, details of the table, along with the column names, will
be specified in the display box for a quick view to the user.
Due to access restrictions and for easier understanding, you shall import
data from another Excel file. Say, you import data from Excel. Data
imported from excel will be displayed under Navigation pane. Users can
load multiple files by selecting the ‘Select multiple items’ checkbox and
checking the desired files.
‘Load To option’ in the navigator pane allows viewing the data in the way
the user wants. Clicking on ‘Load’ will load the data.
Transform
Query and Design tabs will get enabled to the user.
Query tab is used for the transformation/shaping of data.
The design tab helps in improving the look and feel.
Once data is loaded, it will get displayed on excel automatically. The count
of the number of records loaded will be displayed under Workbook Queries.
Query Tab
Click on ‘Edit Query’ in the Query tab. Users can now modify/transform
data without using the normal excel formulas and coding.
Operations in the Query tab
Below are the operations that can be performed in Edit Query:
1. Choose Columns - Allows the user to select the columns that are
needed by the user.
2. Remove Columns - Remove the selected columns from the table.
3. Remove Other Columns - Remove other columns from the table
except for the selected ones.
4. Move - Columns can be reordered.
5. Keep Rows - Keep top rows/Keep bottom rows/ Keep a range of
rows- based on the number of rows specified.
6. Remove Rows - Remove top rows/Remove bottom rows/ Remove
alternate rows- based on the number of rows specified.
7. Remove Duplicates - Remove rows containing duplicate values for
the selected columns.
8. Split Column -Split values in the selected column based on the
delimiter/number of characters.
9. Group by - Group rows based on the selection of columns.
10. Datatype - Change datatype for the specified column(Text,
Decimal, Whole Number, Logical, Date, Time,
Date/Time/Timezone, etc.).
11. First Row as header - First row of the column can be used
as a header.
12. Replace value - Existing value can be replaced with the
specified new value.
13. Append – Consolidate data from different sources and from
multiple tables into one.
14. Merge – More like a join operation to add data.
Values can also be sorted ascending/descending.
Merging Two Tables
If you want to merge two columns together, given the need, Power query
will evaluate the selection and will give the results on how many matches
the selection will return.
To Merge Orders and Returns table, click on the Merge option present in
the ‘Power query’ ribbon. Select the tables and matching columns to create
a merged table. Matching column act as a join condition.
A new column will be added at the end of the table, which has to be
expanded to see the original results.
After expanding the columns, you can see the columns that are merged.
Unmatched rows are displayed with the value null.
Load
Close and Load: Save the changes to the query, close the query editor
window, and load the data to a new workbook.
Applied Steps
The applied steps section shows the operations applied to the data in
sequential order, which helps to keep track of the transformation process.
These steps can also be deleted.
Thus power query excel makes it easy to get data in good shape. It has all
the common transformations. This is of more use comparing to VBA
macros which use coding in data transformation.
Filters in PowerBI
Filters in PowerBI are used to view the data only, which you want to focus
on. Filtering will remove the data from the visual temporarily, and it can be
viewed back once the filter is opted out. Filters enhance the visual
representation of the report.
There are four types of filters in PowerBI.
Page filter
Visual filter
Report filter
Drillthrough filter
2. Report Filter
The report filter applies to all the pages in the report page. A report filter is
very much similar to the page filter. While in page filter, it applies at the
page level. In the case of the report filter, it gets applied at the report level.
All the other properties remain the same.
Example: In the right pane (VISUALIZATIONS), under the FILTERS, you
will be able to see the REPORT LEVEL FILTER. Drag the necessary
column from the dataset and place it in the filter.
Now once you select a specific data from the Report level filter, the whole
report with all the visualizations gets filtered across the pages.
3. Visual Filter
The visual filter applies to a single visual on a report. This filter gets
applied only at the visual level, even if you have created multiple visuals
from the same datasets.
When you apply the visual filter, only the specific visual gets filtered based
on that filter. Similar to page filter, you can have multiple columns added to
a page filter.
By default, all the columns in that visual will get added to that filter. In the
right pane (VISUALIZATIONS), under the FILTERS, you will be able to
see the VISUAL LEVEL FILTER. All columns in the dataset will be added
by default in the filter.
Once the visual filter is applied for the country ‘Australia,’ only the specific
visual is filtered, whereas all the remaining visuals remain the same, not
filtering any data.
Generic Properties for Page, Report, and Visual Filters
There are two filter types in the Page, Report, and Visual filters.
1. Basic Filtering
2. Advanced Filtering
Basic Filtering is filtering the data by just selecting the column values
present in the dropdown. Advanced filtering consists of many options such
as ‘contains,’ ‘starts with’ etc.
1. Drillthrough Filter
With the drillthrough filter in Power BI Desktop, you can navigate from the
one page with high-level data to the destination report page with detailed
data - such as a product, or sales, or country. From any report pages, you
can click on data for that entity and drillthrough to the destination page.
Drillthrough filters help us in situations where you have to navigate from
the main page with high-level data to the detailed data visualization.
Let’s take the below example to see the functionality of the drillthrough
filter.
Consider you are having two pages in the PowerBI report named as
‘Highlevelview’ and ‘DetailedView.’ In the DetailedView, you have all the
salesdetails information, which includes the details salesperson, color,
country, and salesprofit.
DetailedView Page
In this DetailedView page, you are having all the sales details with respect
to country, salesperson, color, etc.
Highlevelview
g eve v ew
In the Highlevelview page, you have the map visual in which you have
added the ‘Country’ as location and ‘Color’ as a legend in the fields.
We have added the Country and Color columns in a high-level page, as we
need to filter the detailed data in the DetailedView through these two fields.
Now to enable the drillthrough filter option, you have to add those two
columns in the ‘Detailedview’ page where you have the detailed
information of data.
Once you add the two columns in the destined page, a back button will be
enabled and shown on the page. Any image can replace this back button. If
you want to replace this image, you have to insert the new image on the
same page and make the action as ‘Back.’
In the right bottom of the page, you have added the columns added in the
Drillthrough filter. Now when you right-click on any color area in the map
and click on the DetailedView , it will take you to the DetailedView page.
(Country- Australia, Color: Green).
Now you will be able to see the DetailedView page. Your DetailedView
page with all the details is filtered based on the (Country- Australia, Color:
Green).
A back arrow on the top can be used to navigate back to the
Highlevelview page.
Slicers
Slicers are the types of visualization in PowerBI, which helps the readers by
enhancing the readability of the report. A slicer is another way of filtering,
which will narrow the data populated in the dataset.
Instead of creating multiple reports dataset to a different set of readers, you
can use slicers to slice the data according to them.
Slicers can be used to:
Display the most often used filter on the report.
The currently filtered state is much visible.
Filters the necessary data and hide the unwanted in the data tables.
Though Slicers are similar to Filters, it has its own advantages and
limitations. Usage of Slicer/Filter must be decided based on the user’s
requirement.
There are different types of slicers available. You can import the slicer from
the PowerBI visuals. Some of the examples are given below.
Chiclet Slicer – Displays image/buttons that act as a filter.
Timeline Slicer – Graphical data range selector for date filtering.
Attribute Slicer – Visualize and search data attributes
Hierarchy Slicer – Slicer with a hierarchy of different fields.
Assigning Slicers to Selective Visuals:
We have an option in PowerBI to assign a slicer to selective visuals. If you
do not want to filter the visual even when sliced, you can opt-out that visual
from that slicer. To enable that, select the slicer visual ‘Country,’ click on
the Format tab, and then select ‘Edit Interactions.’
Now you have enabled the filter for all the visuals except ‘SalesProfilt by
SalesPerson and Country.’ If the ‘Filter’ option is selected, that visual will
be enabled for that visual. If the ‘None’ option is selected, that visual will
not be enabled for that visual.
Once you are done with the changes, when you slice the data using the
slicer, it will filter all the visuals except the one which you marked as
disabled. In the country slicer, select ‘Australia,’ and all the visuals have
been sliced other than ‘SalesProfilt by SalesPerson and Country’ visuals.
Syncing Slicers
In PowerBi, you can also sync the slicer across the pages. If you have to
slice the data in the visuals across all the pages using a single page, you
have to do the below steps.
Click on the slicer.
Click on the View tab and enable sync slicers.
In the right pane, sync slicers will be enabled. Select the pages
which you enable the slicers.
Steps Involved
Step 1: Create a Power BI report with necessary datasets from the sources.
Step 2: Create tables, charts, and graphs based on your requirements.
Step 3: Create some images in the Power BI page for toggling.
Step 4: Enable Bookmarks and selection pane in the Power BI report.
Step 5: Link the images to bookmarks.
In Toggling, you map an image with bookmarks, where bookmarks are
mapped with visuals. So when you select an image in your report, it will
display the visuals which are mapped through bookmarks.
Assuming you have already created a Power BI report with necessary tables
and charts, let us see the process from the 3 rd step.
The Tradeoffs
It might sound that SSBI is a panacea or a holy grail that can meet all the
demands that businesses put in front of a BI platform. The reality, on the
other hand, is far from it. On the one hand, a self-service environment
empowers users to do a lot of reporting and analytics on their own. Still, on
the other hand, it exposes the system to improper usage and might make it
more complex for casual users.
a. Power users might use SSBI to query very large data sets, putting
huge pressure on query performance.
b. Inspired by a new set of sophisticated tools, power users might
create thousands of reports with conflicting and inaccurate data,
making it difficult for casual users to find a relevant report.
c. Many users might end up running a similar query putting
unnecessary pressure on system and network.
d. Making data available from various sources using data
virtualization or shared data views helps the user to get a contextual
sense of analysis. Still, this approach often harms performance.
Available Tools : Many vendors, both big and small, have come up with
self capabilities added to their BI offerings. Following are a few of those
tools:
Microsoft: Power Pivot
Tibco: Spotfire
SAP: Business Objects Explorer
IBM: Cognos Express
Information Builder: Web Focus Visual Discovery
Open Source: BEE Project, Jaspersoft, Pentaho, SpagoBI
Conclusion
So this was all about the strategies to learn the functions of Power BI and
Power Query. By following the above approaches, you can easily learn
Power BI on your own and become a master in power BI. The only thing
you need to focus on while learning Power BI and Power Query is that all
steps need to be followed properly. You can’t skip any step; otherwise, you
will not be able to utilize all the functions of Power BI simply and
efficiently. You will be able to generate intuitive reports easily after going
through the book.
Power BI
An Advanced Guide to Learn
the Advanced Realms of Power BI
DANIEL JONES
Introduction
All businesses are running with the help of data in the form of emails,
printouts, reports, excel sheets, etc. As the business grows, the data also
gets accumulated and reaches a certain level where it is nearly impossible to
find the data you need. In fact, when you have a huge amount of data, it is
possible that you might miss the latest information and using the old
information.
Power BI is one such tool that helps you in getting your job done in an easy
and efficient manner by transforming the data in the form of charts, reports,
graphs, and other visualization techniques. This will make your data more
meaningful and easy to understand with a few clicks. Data insights can be
viewed using intuitive and colorful visual designs instead of using old
tables, lists, and bullets.
Power BI allows you and your co-workers to work simultaneously on the
reports and dashboards using a web browser or smartphone. All the data
gets refreshed and synced automatically, which means you are always
working on the latest data. Thus, no need to worry about the manual
revisions or asking your co-workers to maintain the tracker for changes.
Power BI performs all these tasks for you on its own.
Since the data is now dynamic in nature, you are free to check your data in
an advanced manner for insights, trends, and BI functions. Power BI is such
a powerful tool that you can slice the content on your own and also ask
personalized questions using your own language. All this information is
available 24/7 anytime, anywhere. You will receive alerts from Power BI
once the data is changed from the threshold value set by you.
There are a few main things that Power BI performs, and they are known as
building blocks. Once you have understood the building blocks of Power
BI, you can easily use them to start building complex and intuitive reports.
In fact, all the complex things in Power BI are built with the help of
building blocks only. In real life also, building blocks are the pillars of any
project such as cars, buildings, roads, etc. Now let us see the building
blocks present in Power BI, which help easily create complex things.
1. Visualizations
2. Reports
3. Datasets
4. Dashboards
5. Tiles
Now let us understand each one of them one by one.
Visualizations
It is a visual representation of your data intuitively by using charts, maps,
and other interesting things. Power BI comes with various types of
visualizations, and they are evolving with every new version released. Let
us see the various visualizations present in Power BI service with the help
of the below image.
Image source: Microsoft.com
Visualizations are very simple in nature. They are like a unique number,
which is representing an important thing. They can also be complex if the
issues require a huge amount of data to be shown in the form of a color
map. The main idea behind representing data using visuals is to show such
data, which is very difficult to be shown in the form of text or tables.
Datasets
It is a collection of data that is used by Power BI to start creating the
visualizations. It can be a very simple dataset coming from an excel sheet
workbook like the employee information (Name, Age, Address, Salary,
Date of Joining, etc.)
Datasets are not limited to individual sources. They can be a combination of
more than one data source which is filtered and then combined together.
This results in a unique dataset having all the required data to be used in
Power BI for visualization.
Let us say that you have created a dataset with the help of following
database fields:
1. A table from a website
2. An online survey result
3. An Excel table in your laptop or desktop
This will be a unique combination of 3 different databases. Still, it will be
counted as a single dataset in Power BI, which is pulled from various data
sources.
To take into account the data, which is important to you, filtering plays a
very important role in Power BI. Let us say you have filtered the contact
database in such a way that only those users who have received your online
survey link are included in the Power BI dataset. Then you can easily create
visuals with those filtered dataset collections of users whom you invited for
taking the survey. Therefore, filtering will surely help you to focus on the
data you need to be considered.
A very important feature in Power BI is a large number of data connectors
present in it. Power BI provides the data to be connected from every major
data source like Microsoft SQL, Excel workbook, Oracle, Azure,
Salesforce, Facebook, MailChimp, and more. With the help of Power BI,
you can easily connect to the data sources, filter them using the required
options, and finally put in your Power BI dataset for further processing.
Once you have the required dataset handy, you are free to start creating
visualizations to display the data in different formats and designs to
understand the insights proficiently. This is where the role of Power BI
Reports comes in.
Reports
It is a combined collection of visuals created by you, and they appear
together in one or multiple pages. It is like a normal report which you create
for a meeting presentation with your peers. It is a collection of data that are
inter-related to each other in one form or the other. You are also free to
create reports with the help of the Power BI service.
Reports help you in creating various visualizations and then arrange them in
your own order as per the needs & requirements. The report can be for
anything from quarterly company results to the sales growth.
Dashboards
Once you have created the report and it is ready to be shared, then you will
create a dashboard for the same. A dashboard is a collection of the visuals
taken from one page, which is then shared with others. It can be shared with
those users who will be providing insights into the data.
It is a mandatory requirement that the dashboard should integrate inside a
single page. That page is known as a canvas where you drop the
visualizations in an empty space. You are free to share the dashboards with
other users for interaction. It can be opened in the mobile device or Power
BI service.
Tiles
It is a single visualization of the dashboard or a report. It is a rectangle-
shaped box that will hold a particular visual. A tile can be surrounded by
multiple tiles as well. While creating a dashboard or report, you are free to
move the tiles in any order as per your needs and requirements. A tile can
be made larger, its height or width can be changed, and it can hover over
other tiles.
If you are not the owner of the report or the dashboard, you will be able
only to view it. It means it is only a read-only mode, and you can’t modify
it in any manner what so ever. You are only authorized to interact with it,
that’s all.
Combined Together
So we saw all the building blocks of Power BI in the above sections.
Therefore, Power BI is a collection of apps, services, and data connectors
that help you to bring the data from various sources. Then you filter them as
required and finally move it to Power BI reports or dashboards to crate
intuitive and appealing visualizations to be shared with other users.
Since Power BI is backed by Microsoft, you can always trust that even the
complex datasets can be presented in a straightforward manner, and further
expansion can be done with a few clicks. Now let us see how Power BI
service works.
Power BI Desktop
It is a free to use desktop application for laptops and personal computers
which allows you to collect, transform, and finally visualize the data in
Power BI. One thing worth noting here is that Power BI Desktop works
along with Power BI Service. For creating the dashboards and reports, you
need to work in Power BI Desktop. For publishing the created dashboards
and reports, Power BI Service is used. So, in short, both of them work
parallel together.
If you are wondering where you will get the sample data to create reports
and dashboards, don’t worry. You can easily get the sample data for the
Excel workbook at this link . Then you can import the data in the Power BI
Desktop by selecting “Get Data” -> Excel.
The very first step is to understand the Power BI Desktop’s GUI (Graphical
User Interface). Once you launch it on your computer or laptop, it will show
“Getting Started” pop up on the screen. It will contain all the important
links and resources for blogs, videos, forums, FAQs, and other support. You
can visit the same for gaining more knowledge on the same, or you can
close the pop up for now and get back to it at a later stage.
The very first step in Power BI Desktop is to build reports using the
“Reports” view. Here mainly there are five areas which you need to take
care of. They are Ribbon, Canvas, Pages tab, Visualization Pane, and Fields
Pane. All of them are used for different functionalities while creating
reports.
Chapter 2
Power BI Reports
Once you have started working on Power BI, it becomes very easy to create
the best reports with the help of dynamic datasets and insights. There are
many advanced functionalities and features present in Power BI Desktop.
You can easily create advanced queries, create new relationships among
different tables, mashup the huge amount of data from various data sources,
etc.
There is a “Report View” section in the Power BI Desktop, which allows
you to create more than one-page reports full of visualizations and charts. It
provides a top-notch design experience to the users, which is pretty similar
to the one that of editing view inside Power BI Service. It allows you to
move the visualizations on the canvas, merge the visualizations, copy &
paste, and more.
The main difference between Power BI Desktop and Power BI Service is
that while working in Power BI Desktop, you are free to write your own
queries and then model the data in such a way that it supports required
insights for your Power BI reports. Once it is done, you have to save the file
on your computer, laptop, or cloud.
When loading the data for the first time in Power BI Desktop, a blank
canvas will appear where it will have the Report view. With the help of
icons present at the left side of the canvas navigation pane, you can easily
switch between Data, Report, and Relationship. It will be like the below
image.
As soon as you are done with adding the data, fields can be added to the
visualization inside the canvas. If you wish to change the visualization type,
simply select it, and then choose a new type from Visualizations.
One thing to note here is that a minimum one empty page is required to
create a report. All the pages are shown on the screen, which is on the left
side of the canvas.
You are free to add as many visualizations as you want on a page, but you
have to keep in mind that they are not over the limit as well. This is because
having a huge amount of visualizations on a single page will make the page
look dull and unnecessarily filled up with too much information. This is not
a good practice, and you should try to avoid it as much as you can. In order
to add new pages to your report, you can click on the “New Page” present
in the ribbon.
If you wish to delete a page, you can do it by selecting the X (cross) button
present at the bottom of the page in the Report view. One thing worth
noting here is that when you are using Power BI Desktop, visualizations
and reports are not allowed to be pinned on a dashboard. In order to do so,
you have to go to the Power BI site and then publish it from there.
Copy-Paste Reports
It is very simple to take a screenshot of the visual using a report from Power
BI Desktop and then to paste it to any other report in the Power BI. You
only need to use the command Ctrl + C for copying the visual report. Then
move on to the different Power BI Desktop report and use the command
Ctrl + V to paste it there. You are free to select an individual visual or more
than one visual present on a page while copying. Similarly, as per your
decision, the paste will happen in the other report.
This copy/paste functionality is very handy if you like to create or modify
multiple reports in a short span of time. This is because when you are
copying the reports, all the formatting and the internal settings which are set
by you in the formatting pane will automatically get applied to the
destination report. Thus, if you rely on a particular formatting for your
reports, you don’t need to worry much, and Power BI will take care of the
same.
You will get an error or a warning if the fields present in your model are
different. The warning might also come if the fields do not exist anymore.
This happens when you have already deleted a field in the model which
another visual was using at the same time. In order to resolve this issue, you
simply need to change the broken fields with the ones you have used in
your actual model while pasting the visual. In case you have used a
customized visual, you have to import the same customized visual at the
destination report.
URL Filters
They are the filters that are added to Power BI's new pane with the help of a
URL query parameter. If you are a user having the Edit permission in
Power BI reports, then you are allowed to edit, clear, or delete this filter
present in the new pane. You won’t be able to hide, rename, sort, or lock the
filter. This is because the filter is related and linked to the URL parameter.
If you want to remove this filter from your report, you need to remove the
particular parameter from the URL.
Filters Pane
Filter pane is used to display the tables and the fields present in the Power
BI report. It also shows the applied filters in the report. You are allowed to
apply the filters directly in Filters pane, or you can also make the selections
using slicers. Basically, there are four types of filters, namely: Page filters,
Visual filters, Report filters, and Drillthrough filters. Each one of them
covers different areas on the Power BI report.
Suppose a filter has a note “All” beside it, then all values present in that
field have been included.
The filtering capability depends upon the mode used to interact with the
reports. It means filtering is different for Reading view mode and Editing
view mode.
You are allowed to add all the filters in the editing view. It means as soon as
you save the Power BI report, all the filters will automatically get saved and
are synced to the mobile app also. Users who are reading the report in the
Reading view will be able to interact with your filters, but they are not
allowed to add any new filters to the report.
Whereas in the reading view, interacting with all filters already present in
the report is allowed. You can also save your selections, but adding new
filters to the report is not allowed. You are allowed to explore data present
in the report by changing or altering the existing filters. All the changes get
updated in real-time and get synced to the mobile app as well. Whenever
you close the report, all the filters get saved. In order to undo your filters
and go back to default settings for filters, you can click on the “Reset to
default” option present at the top of the screen.
You can select an axis label or a value from the visual in order to highlight
the remaining visuals present in the page report. If you want to remove the
highlighted ones, the clock on the value once again and choose the
unoccupied space. This is known as Ad hoc highlighting.
Chapter 3
Since June 2017 onwards with the release of Power BI Desktop and
important version updates for Power BI service, you now have a new line
sampling algorithm in Power BI. It improves the visuals in Power BI, which
are having high-density data. Let us say you have created a line chart using
the sales figures from your retail stores, and every individual store has more
than lakhs of sales invoice throughout the year. Therefore, a line chart for
such data will be sampling the data into meaningful information to
showcase each store’s data as well as create multi-line charts to display
underlying data. It is a common algorithm used to visualize high-density
data in Power BI. It improves the sampling of data in an efficient manner.
2. You need to check that every column in the table has a valid and
relevant name. This is required because it makes it easy to find
relevant data while creating Power BI reports.
3. You can keep your file anywhere on your computer—no need to
keep in a pre-defined particular drive like C drive or D drive. Just
open Power BI, navigate to “Get Data” -> Files -> Local File. A
dialog box will open where you have to select the Excel workbook
you want to import.
4. Once the excel file is imported in Power BI, the report creation
process can start. Note: It is not necessary for the excel file to be
present on your computer only. It can be on SharePoint or OneDrive
as well.
Once the above steps are completed, you will find a new dataset present in
Power BI under the heading Datasets. You are now free to explore the data
by creating dashboards and reports.
1. Choose the “Open Menu” icon present besides the dataset.
2. Now click on Explore. It will open a blank canvas on the screen.
3. Towards the right-hand side on the screen, you will find your tables
as well their columns under the “Fields” section.
4. Now you have to choose the field(s) which you would like to
present in your canvas visualization. Changing the visualization
type, applying filters, and modifying relevant properties can be
done from the “Visualizations” section.
Note: Data can also be imported using advanced features such as Power
Query, Power View, and Power Pivot.
Real-time streaming allows you to stream the data and get up to date
dashboards instantly. Any dashboard or visual which is made in Power BI is
eligible to be displayed as well as updated in real-time. Streaming data
sources are social media posts, factory sensors, service metrics, and more.
In fact, all the devices having time-sensitive data in it are used for
transmission.
Here you will learn how to set up the streaming in real-time. Let us first see
the various types of real-time datasets designed to be used for showing in
dashboards and tiles.
Push Dataset
This dataset is used to push the data in Power BI. When you create a dataset
in Power BI, a new database gets created in the service which is used to
store data. Because you have this underlying database ready to store the
Power BI data, you can create reports using the same. The visuals and the
reports will be similar to the normal Power BI reports and can be used to
create alerts, pin down to dashboards, etc.
As soon as the report gets created with the help of a push dataset, all its
visuals are eligible to be pinned down on a dashboard in Power BI. All
those visuals will be updated and synced in real-time if there is any change
in the data. The dashboard triggers a refresh each time new data comes in
the service.
Couple of points to note here are:
1. If you pin the complete report by using the “Pin Live Page” feature,
then the data will not get updated automatically.
2. When a visual gets pinned down on a dashboard, you will be able to
use the Q&A feature for asking questions to the push dataset. After
you have created a query for Q&A, you are allowed to pin the
visual back on the dashboard so that it gets real-time updates.
Streaming Dataset
By using the streaming dataset, you will be pushing the data in Power BI
service. But there is one difference with respect to push dataset. Power BI
stores your data in a temporary cache, and it gets expired very quickly. The
cache is mainly used to show the visuals having a transient history like a
line chart, which expires after 60 minutes.
There isn’t any underlying database in the streaming dataset, and thus you
will not be able to create report visuals with data present in the stream.
Also, you will not be able to use certain features like Power BI visuals, data
filtering, etc.
There is only one option for visualizing the streaming dataset. You need to
add a tile first and then make use of a streaming dataset in the form of a
“custom streaming data source.” In order to display real-time data quickly,
customized streaming tiles are optimized. There exists very little inactivity
time in between the data getting pushed in Power BI service and visual
getting updated. This is because data is not required to be read or entered
into the database.
In practical scenarios where it is important to reduce the inactivity time
between data getting pushed and when the data gets visualized, streaming
datasets are used. As a best practice in Power BI, you need to push the data
in such a format which gets visualized as it is and doesn’t require any
modifications. The examples for such types of data are pre-calculated
averages and temperatures.
By now, you must have understood that you can directly publish the
workbooks using Microsoft Excel 2016 and later versions into Power BI. It
can then be used for creating intuitive and creative dashboards as well as
reports. All of them can be shared with other co-workers for collaboration.
When you publish an Excel workbook into the Power BI, you need to take
care of a few things like the below ones:
1. You must be using the same account for Office, OneDrive
(Business), and Power BI to publish the workbook.
2. You are not allowed to publish a workbook that is not having any
data in it and is completely empty. Also, it is not allowed to publish
a workbook having unsupportive content with respect to Power BI.
3. You are not allowed to publish the workbook, which is either
password protected or encrypted with Protection Management.
4. You must enable the modern authentication before publishing the
workbook. If it is not enabled, the Publish button will be either
greyed out or not present in the menu.
Upload Option
In this option, the workbook will be similar to how it looks in Microsoft
Excel Online. But only limited features will be present for pinning the
elements on the dashboards from the worksheet.
Editing the workbook is not allowed in Power BI. For making any changes
in the data, click the Edit button. Now open in in Excel on your computer or
online. Now those changes will be saved in OneDrive (Business). Also,
datasets will not be created automatically. The uploaded workbooks will be
given a unique icon to identify them like the ones that are uploaded and not
imported.
You should wisely use the Upload option if there are Charts, Pivot Tables,
or data in worksheets that are required in Power BI.
Export Option
In this option, all the table data and the data model will be exported in the
newly created dataset. If there are any Power View sheets, those will be
created again in the form of reports.
You are allowed to edit the workbook directly, and the changes will
automatically get in sync with the dataset present in the Power BI interface
in every 60 minutes. If it is an urgent update, you can use the Publish option
present in Excel to get the changes updated instantly. All the visualizations
will be updated as well.
So you can use any option from the above ones. Once it is done, Microsoft
Excel will automatically sign in to Power BI using the current account.
Then it will publish it and you will able to check the progress. Once the
process is complete, you will get a successful message, as shown in the
below image.
Power BI offers you a way of making your reports even more dynamic by
using parameters. These can be used to substitute query filters, connection
information, and calculations in your queries.
In Power BI Desktop, parameters can be defined for use in many ways
when you work with datasets. Creating them is simple, and you can add
them in at the import stage or later if you want a dataset redefined or
dynamic elements added. As an example, you could create parameters to
provide a data source with connection information or parameters that
supply predefined values for when you want to filter data.
We are going to focus on creating parameters that we can use with data that
we import from an instance of a local SQL Server, using the data from a
database named AdventureWorks2017.
Connection-Specific Parameters
Power BI already contains some data source connections that allow you to
use parameters when you are defining the properties for the connections;
examples include SQL Server, Salesforce Objects, and SharePoint. Let’s
say that you want to get some data from SQL Server; you can use two
parameters – one for the Server instance and one for the target database.
The parameters are not dependent on any dataset, and that means they can
be created before or after you add a dataset. However, they must be defined,
and their initial values must be set in Query Editor. When you create a
parameter, you will see it in the Queries pane; here, you can also view the
values, update, and reconfigure settings if needed.
We are going to retrieve some data from an SQL Server database, and, for
that, we need a pair of connection parameters. The first one will list all the
Server instances that may be a host for the source data – for our example,
we only need a single instance; the rest will just demonstrate having
multiple instances.
First, open Query Editor and go to the Home ribbon. Click on the down
arrow beside Manage Parameters and click on New Parameter. The dialog
box opens, go to the Name text box and type SlqSrvInstance. Go to the
Description box and type in a description for it.
Click on Type and choose Text from the drop-down menu. Then click on
Suggested Values and click on List of Values. A grid will open; this is
where the individual values are types for assigning to the variable. Make
sure that a minimum of one value matches the name of a real SQL Server
instance. The values to type in for this example are:
.\SqlSrv17a
.\SqlSrv17b
.\SqlSrv17c
When the values have been typed in, choose a default from the drop-down
menu, and then go to the Current Value menu and choose the current value
for the variable. We’ll use SqlSrv17a as both values.
Close the Parameters box by clicking on OK, and the parameter will be
placed int eh Queries pane; the parentheses show the current value. When
you click to select a parameter, you will see the button for Manage
Parameter and the Current Value menu in the primary pane. To change the
current value, choose a new one from the menu or change the settings
through the Manage Parameter.
Now we need a target database parameter; follow the same process, but
make sure the parameter is named as Database. Make sure a minimum of
one real database is shown in the list. After you click OK, the parameter is
added to Queries again. For our database, we will use the values:
AdventureWorks2014
AdventureWorks2015
AdventureWorks2016
That’s it; you have created two connection parameters. Your parameters can
be configured with other data types if you require them, such as dates or
decimals, or different formats for the values. For example, the parameter
can be changed, so it takes any value or one from a list query. List queries
can be created manually with an M statement or based on a dataset.
The data you use for Power BI can come from several different sources,
but, more often than not, SQL Server will be used for hosting it. We’re
going to look at how you can work with SQL Server data and the
relationships that exist between tables.
Power BI Desktop is far more robust than the Power BI service for business
intelligence reports because it offers support for many more data sources,
and it has more tools for you to use in transforming your data.
SQL Server is one of those data sources that can only be used in Power BI
Desktop, not in Power BI service. Although the service does give us the
connectors for SQL Data Warehouse and Azure SQL Database, it doesn’t
offer the ones we need for SQL Server. The Power BI Desktop lets us
access SQL Server data from whole tables or allows us to run queries that
will return just a subset of the data from several different tables. Stored
procedures can be called, including the one that allows you to run both R
and Python scripts – sp_execute_external_script.
We’re going to delve into how we retrieve the data from an instance of the
SQL Server and look at some different ways the data can be returned. As
with the last chapter, we are using the AdventureWorks2017 database, and
we are running it on a local SQL Server instance.
Most of what we discuss here can easily be used on any other RDBMS –
Relational Database Management System – and on multiple data source
types. All data in Power BI is organized into queries, which are structures
similar to tables and used when we work with datasets. Because of that,
once the data is in the Desktop, most of the actions you do are likely to be
similar, regardless of where the data came from. You will come across
features that are specific to a relational database, though, especially when
you are looking at the relationships between the tables.
One of the more powerful features for helping you to comply with SOX,
HIPAA, and other regulations is SQL Server Audit. However, viewing data
collected with the feature is not easy. In our final chapter, I want to show
you how you view your SQL Server Audit data and filter it using Power BI.
Business database teams are permanently involved in trying to comply with
certain regulations, such as SOX (Sarbanes-Oxley Act, 2002) and HIPAA
(Health Insurance Portability and Accountability Act, 1996) and these
teams tend to make auditing one of the common parts of their strategies as a
way of helping them track any threats to their data. As an example, if a
team is running SQL Server, they might use Audit as a way of logging both
database and server actions.
SQL Server Audit is already in the database engine, and, from SQL Server
2016 onwards, it is freely available in every edition of SQL Server.
If your organization is a DBA (Doing Business As) and your job is to
implement Audit, you will see that it is pretty easy to set up. The hardest
part is in working out what user actions need to be audited, how large
amounts of data might be handled for audit, and what the best tools are for
monitoring the data and reviewing it.
However, important though these considerations are, for the purpose of this
chapter, we’re going to focus on the final bit – monitoring the data and
reviewing it. With SQL Server, you get an easy way to collect data, but you
don’t get any meaningful way of working with the data; all you can do is
manually review it.
Perhaps the best way is to use Power BI. With this, you can quickly create
reports that give you some visual insight into your data. Power BI isn’t
really designed for the purpose of audits and alerts, not as much as some
other dedicated management tools are, but it does allow you to track user
behavior relatively easily. And Power BI Service and Desktop are both free
to use.
I will be showing you, through a series of examples, how to use Power BI
and SQL Server Audit data; we’ll look at how to set your test environment
up, how to generate some audit data to work with, how to get that data into
Power BI Desktop and how to come up with a report containing both
visualizations and tables.
Do bear in mind that Power BI Desktop and SQL Server Audit are very
powerful, and we cannot possibly cover everything they can do in this
section. What I can do is offer you a basic overview of how you can use the
tools together and how to get started with reviewing audit data using Power
BI.
Adding Tables
One good way of showing data is to make some of it available in table
form. The data can be filtered as you want, depending on what you need for
your audit strategy. You can also add slicers to filter the data in a specific
way, for example, by Users, Actions, and Successes and Failures.
When a filter is applied, the data in the table is updated by Power BI, based
entirely on the values you chose. Doing this gives you an easy way of
accessing the different data categories without having to go through it all
manually or having to generate a T-SQL statement each time you want
different information
Adding a Matrix
Another good way to get some quick data insights is to summarize the data
using a matrix. You could, for example, add a matrix showing how many
actions each user took and what those actions were. You will spot, on the
matrix page, a list of user actions on the right side – one of these is called
ROLLBACK; the ROLLBACK statement is required when the main
statement fails, such as when there are no permissions for a certain action.
Slicers can also be added to the matrix report page, allowing you to filter
the data as you need it. The matrix is incredibly useful because it can be set
up, so it drills down into your data, i.e., into how many actions were
successes or failures. When you set this up, you decide the order each layer
is presented in, dependent on what type of data you are using and what its
hierarchical nature is.
Adding Visualizations
Lots of different visualizations are supported in Power BI Desktop, and you
also have the ability to import others. Make sure you only use the
visualizations that help explain your data clearly. Say, for example, that
your report page shows three visualization types; each one gives a different
perspective into your data. You can filter the ROLLBACK actions out; that
way, your visualizations will only reflect the user-initiated statements,
instead of those that are response-generated.
Look at the figure above; on the left, the clustered bar chart shows the data
grouped by the user, providing a total number of actions per user. The DML
action indicates that all three user accounts have the same total – that will
depend on how many times the statements were run.
At the top right, another clustered bar chart shows the data grouped by the
user again, but, this time, showing how many successes and failures there
were for each group. This way, you can see which users are trying to run
statements they don’t have permission for.
At the bottom-right, you can see a donut chart. This shows the same data as
is in the clustered bar chart above but from a different perspective.
Hovering over any one of the elements shows you the total action
percentage.
What all this is showing you is that you can use the same data in different
visualizations to see what works and what doesn’t.
When elements are placed on one report page, they are tied together
automatically by Power BI. By doing this, you can choose an element from
one visualization, and that choice is reflected in the others.
Adding a Gauge
Lastly, you can also add gauges, cards, KPIs (key performance indicators),
and other elements to your reports. You could add a gauge that shows how
many ROLLBACK statements were executed as a response to failed
attempts at running T-SQL statements.
By adding a slicer, you can also see other data, for example, if each user
were hitting the threshold specified. When you select a user in the slicer,
you need to specify a target value. This is important because it means that
target value is used to set alerts in Power BI Service – this cannot be done
in Power BI Desktop – but you will require a Power BI Pro license to make
use of these features. Alerts can also be set to generate regular email
notifications, to KPI visuals and cards.
Thank you for taking the time to read my guide. I hope you now have a
better understanding of some of the advanced features in Power BI.
I have not even scratched the surface with this; Power BI is incredibly
complex, and it offers so many different features that it would take an entire
series of guides – long ones at that – to try and explain them all. What I
have done, I hope, is to give you an idea of some of the more common
advanced features you might use in Power BI to create reports and visualize
your data in dynamic and interesting ways.
What you should do now is take what you have learned here and build on it.
There are plenty of online courses you can take to further your knowledge,
and, really, the best way to get to grips with it all is simply to use it. Create
a dataset and play about with it. Apply new features, new visualizations and
learn what its all about and what Power BI service and Power BI Desktop
can do for you.