Power BI - 3 in 1 - Beginne...
Power BI - 3 in 1 - Beginne...
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 Beginner’s Guide to
Learn the Basics of Power BI from A-Z
Introduction
Who is this Book meant For?
What is Covered in the Book?
Chapter One: Introduction to Power BI
Who are the People Using Power BI, and Why?
Important Features of Power BI
How to Download Power BI
Getting Acquainted with Power BI
Power BI Desktop Options
Uploading Data into Power BI
How to Create your First Visualization
How to Create a Visual Manually
How to Arrange your Dashboard
The Interaction of Multiple Visuals on a Dashboard
Introduction to Quick Insights
Formatting of Reports
Modifying a Report
Chapter Two: Sharing the Dashboard
How to Invite a User to View a Dashboard
How to Create a Workspace
How to Share a Report on Mobile Devices
Chapter Three: Loading Data from Different Sources
Power BI Desktop Query Editor
The Different Data Sources Allowed on Power BI
How to Load a CSV Data File
How to Load an XML Data File
How to Load an Excel Data File
How to Import Queries and Models Created in Excel to Power BI
How to Load a Windows Access File or Database
How to Load a JSON Data File
How to Load an Entire Folder into Power BI
How to Load Selected Files in a Folder
How to Create your Own Data on Power BI Desktop
Database Data Source
How to Import Data from SQL Server
How to Import Data from ODBC Sources
Chapter Four: Data Transformation
Power BI Desktop Query Editor
The Power BI Query Editor Environment
Add Columns
View
Transformation Steps in the Query Editor
Restructuring the Data in a Query
Filtering the Data in a Query
Chapter Five: Data Models
How to Create a Data Model in Power BI
Power BI’s Data View Window
Exploiting Tables
Creating Hierarchies
Creating Joining’s between Tables
Relationship View
Managing Relationships
Classifying Data
Arranging Data in the Data Model
Creating Sort- By for Data Model
Connecting Column Contents
Selecting the Right Table for Joined Calculations
How to carry out Logical Functions
Carrying Out Basic Aggregations
Conclusion
Resources
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
DANIEL JONES
Introduction
The features that are essential for your tutorial will be explained in the
appropriate chapter in the book.
Since Mike is not interested in any of the options given, he clears the menu
by clicking the “X” symbol at the top of the menu. He proceeds to Sign in
with his Microsoft 365 Office account.
He uses his work email to register and sign in as Power BI does not allow
personal emails like “[email protected] or
[email protected].”
NB: The preferred email format allowed is “[email protected]”
Once he signs in, he is directed to a blank Power BI Window (environment).
Here, he notices the dashboard canvas, the Power BI ribbon at the top of the
screen, the view type at the top left side of the screen under the ribbon, the
page selector at the bottom left side of the screen, and the visualization
properties and field lists at the right side of the screen. Generally, the
environment is simple and organized for easy access. The functions of each
the options listed above include:
_ Power BI Ribbon: These contain the categories of features needed to
develop dashboards on Power BI. The categories on the ribbon are:
File
Home
View
Modeling
Help
_ Dashboard Canvas: this is the whiteboard that takes up about 80% of the
window. Designing of visualizations and dashboards take place here
_ Visualization Pane and Palette: the pane is the area for filtering and
allocation of element attribute. Formatting of prepared visualization also
occurs here. The palette contains the sample structure of all the possible
visualizations on Power BI. Selection of the shape of a visual takes place
here.
_ Fields list: contains all the fields in the source data that can be used to
create a visualization
_ Page selector: it is used to switch from one page to another
Uploading Data into Power BI
Mike Edwards finds what he is looking for on the Home ribbon, after
observing the components of each tab on the ribbon. He was looking for a
way to upload the data he has into the software. He sees “Get Data” and
clicks on it. This brings up a dialog box, which shows him all the possible
places he can import data from. Since the data he has is in Excel format, he
selects Excel and clicks “Connect.”
Windows Open File dialog pops up, and he selects the location of his data
file, in this case, RegionBudgets.xlsx. Immediately he opened the file; Power
BI started the uploading process.
The third column shows the month of the year, and its relevance depends on
the fourth to the seventh column. The fourth to sixth column shows the sales
of the product per month. The seventh column shows the budget allocated to
each country for each brand per month.
The fields column highlights each of the columns in the Excel file Mike
uploaded.
Country/region
Brand
Month
Sale 2016
Sale 2017
Sale 2018
The country field has a globe symbol in front of it, which means Power BI
recognizes the column contains the name of several countries. The fourth to
the seventh field has the “Σ” symbol in front of it. This means that Power BI
recognizes the fact that the column comprises of only figures.
NB: If Power BI does not recognize the components of your data, it might
create a problem for you when trying to create a visual.
Mike wants to create a visual for the sales of each cigar brand per month, but
he is quite confused about what to do next, he notices a button on the home
ribbon and decides to use it. The button is called “Ask a Question.” He clicks
the button, and it produces an input box. He types in “create a visual for sales
by month.” Power BI automatically generates the necessary column from his
data. Mike isn’t satisfied with just the column, he wants a visual. Being a
naturally curious and intuitive person, Mike clicks on the type of visual he
wants to create with the columns Power BI generated. He clicks on the
“Clustered Column Chart” on the visualization pane (to find out the name of
a visual on Power BI, hover your pointer on the shape and the name will
automatically come up). Alas, a visual is automatically generated on the
column Power BI generated.
How did this happen? With Power BI, it is possible to carry out operations by
asking questions. The feature that allows this to happen is called natural
language queries. With this feature, you can ask Power BI to perform
operations, in the same manner, you ask your colleague or junior to perform
an operation. Not only will Power understand your question (query), it will
also suggest meaningful actions it can perform on your data. This feature
does not require the user to have any previous skill on Power BI, you just
need to have an idea of the type of visuals you want and the feature will help
you bring it to life.
To save the visual created, click on the pin button in the top right corner of
the visual on the desktop. This will save the visual to your dashboard, and it
will be available to you on any device you connect to your Power BI. When
you click on the pin button, a dialog box will pop-up about where to store the
visual and what to name it. If it’s a free Microsoft account, you will only be
able to save to existing dashboard. You can name the visual anyhow you like,
as long as you remember what the name represents.
Arranging a Visual
To do this, you need multiple visuals on the page.
Resize the visual on the page with the steps above
When you are done resizing, click on the blank white space on
the dashboard to deselect the visual
Create another visual by selecting the necessary fields and a
visualization of your choice.
Immediately a different visual will be created on the page. Adjust
and resize it to your taste.
To see the interaction between the four visuals created, Mike clicked on the
slicer visual and selected one of the brands, for example, Champion. If you
were able to get or create a data similar to the one Mike has and performed
the actions Mike performed above, you would notice the change that occurs
across all four visuals. The clustered column changed to show only the sales
of Champion in the three countries, the map didn’t change because all four
brands were sold in the same countries, and the matrix changed to only
include the total amount generated for the sales of Champion brand in all
three countries. Check out the difference in the visual below and the visual in
the previous image.
The same type of changes that occurred above will happen again upon the
selection of another brand in the slicer.
To check this out, Mike selected Victory II in the slicer and noticed that all
the visuals changed to reflect only the properties of Victory II. He selected
the other brands available and noted similar changes.
This change does not only happen when an option in the slicer is selected.
Out of curiosity, Mike clicked on one of the countries (Germany) on the Map.
The visuals changed to highlight the sales that happened in the country. The
clustered column chart changed to reflect the sales of each brand in the
country and dulled the remaining, the matrix changed to show the total sales
the country generated in 2016. There is no change in the slicer because the
same brands were sold in the three countries. Check out the visual Mike was
able to produce by selecting a country on the map visual:
As you can see, clicking on a particular point in a visual may result in a
change in all the visuals on a dashboard. Play around by selecting random
points to notice the change it will cause, you will learn this way because the
next time you are creating a visual similar to this, you will know how to bring
to life the kind of dashboard you want.
This shows the dependence and interactivity of dashboards on Power BI. This
feature is only a little example of the powerful features Power BI has to offer.
If your report is not in any of the visuals above, the analyze option will not
show up when you right-click the report. When the Analyze button is
selected, it will bring up another option, “Find where this distribution is
different.” Click on that option too, and an analysis will be performed on
your report. The analysis can be generated within seconds, or it can take
longer, it depends on the size of the report.
Mike wants to know if he missed something in the analysis of his report, so
he decided to try out the Quick Insights feature. The report he wants to check
is the third visual he created, the clustered column chart on the sales of 2016.
The analysis of the report took about two seconds, then generated two quick
insights, one on sales 2016, the other one on month.
Since Power BI does not have any previous knowledge of your business or its
economic condition, it will only interpret the result based on the data
uploaded. It cannot imitate your brain’s understanding when interpreting the
numbers, therefore quick insights should only be used when you want to
confirm an analysis, find out if there is something you missed in the
interpretation of your data, or to generate fresh ideas. In some cases, the
quick analysis insights produce may not be relevant to the purpose of the
report, but this is very rare, and if it does happen, it will likely reveal a hidden
gem in the numbers causing the deflection from the course.
Formatting of Reports
With Power BI, a user can create multiple visuals in record-breaking time.
The visuals are contained within a report. Most times, professionals use
Power BI with the intention of generating a report for presentation during a
meeting. Just creating a visual is not enough, the report has to be arranged,
decorated, and formatted to be presentable to colleagues. Power BI offers a
lot of ways to enhance the look and feel of a report resulting in a presentation
that will leave your audience in awe of your presentation skills.
How to format a report
The process of formatting a report is not so difficult as Power BI does not
require a different technique to format each type of visual. Therefore, you
only need to learn a few basic techniques.
Create a visual.
Make sure the visual is still selected, then click on the Format
icon in the visualization pane. The icon is in the form of a paint
roller.
The format icon will generate a drop-down menu with the
following options.
General
Legend
X-axis
Y-axis
Data colors
Data labels
Plot area
Title
Background
Lock aspect
Border
Tooltip
Search
Style
Grid
Column headers
Row headers
Values
Subtotals
Grand total
Field formatting
Conditional formatting
Category label
Word wrap
Selection controls
Slicer head
Items, etc.
Not all the options listed above will come up for one visual. The options that
are featured in the drop-down menu depends on the type of visual selected.
NB: It is possible to format multiple visuals at the same time as long as they
are of the same type. Two clustered column charts can be formatted at the
same time, while a map and a slicer can never be formatted at the same time.
The major reason for this is because the formatting pane will generate
different format options for a map and a slicer, and this can’t be joined
together.
Borders
This formatting option is common to all the visuals on Power BI. It creates a
boundary around the visual that separates it from other visuals. To create a
border
Click on the visual
Click on the paint roller symbol
Scroll down till you see the border option and click on it
Turn the switch button on
Select the color of the border
Adjust the size of the border to your taste
Background Color
The option of a background color is also available to all visuals on Power BI.
This option allows a user to change the background color of a visual and
differentiate it from others, especially if the visuals are of the same type and
have similar data. All visuals have a default background color, white. To
change the default color
Click on the visual that needs a change in background
Click on the format icon (paint roller)
Scroll down to back-ground color
You do not need to switch it on as it is already on, all you need to
do is to select a color from the palette and adjust the transparency
until you are satisfied.
Titles
While the title formatting option is not available to all visuals, it’s quite
relevant to the message and delivery of some. You can use the automatically
generated title of some visuals based on the selected fields, or you can adjust
it to a title of your choice. To change the default title of a visual
Click on the visual
Click on the format icon in the visualization pane
Scroll down to the title option, switch it on if it isn’t
From the drop-down menu created, type in the new title you
want, the color of the title, the background color of the title
ribbon, the font, alignment, and the size of the title.
Grid
This option is particularly used for visuals containing rows and columns,
such as table and matrix. The grid option adds lines (gridlines) to separate the
values in a table visual. To create a grid
Select the visual you want to grid
Click the format icon
Scroll down to the grid option
You have two options, a vertical grid and (or) a horizontal grid
For the vertical grid, select the color of the grid
Adjust the size of the text in the visual
Adjust the outline weight (thickness of grid)
Select the row padding and the image height.
For the horizontal grid, there are two additional options of
“horizontal grid color” and “horizontal grid thickness.”
NB: You can activate both types of grid, but you have to do it one after the
other. Finish filling in the requirements of the first one before switching to
the other type of grid off.
Data Colors
This is available to all visuals with a color. The option allows the user to
decide what color is best to represent the data. Giving data a color makes it
different from other data in the visual, and during a presentation, it will be
easy to identify a particular data point. To change the color of a data on
Power BI;
Click on the visual
Click on the format icon in the visualization pane
Scroll down till you see data color, it will generate a drop-down
menu which contains all the default color of your data.
Click on the group of data whose color you want to change and
click on your desired color from the palette. Automatically the
color of the data will change in the visual.
There are many more formatting options available on Power BI, the ones
mention above are just the basic options that you can adjust in minutes. If you
want to explore other format options, create each type of visual on the
visualization pane, and adjust the format options available to find out their
uses. This should only be done for practice visuals as it may not end up in a
visual that is presentable. The only thing you will gain from such a visual is
the knowledge of what the formatting option does and how to apply it.
Modifying a Report
You already know how to create a report, now you need to know how to
manage and modify it. This will involve the creation of new pages, the
renaming of pages, the deletions of pages, the moving of pages, the
duplication of pages, and scrolling through numerous pages. The pages on
Power BI are much similar to those on Excel, the way Excel users can
separate data on different pages, Power BI users can also separate visuals on
different pages.
It does not take blood and sweat to move a page, it can be done in two
seconds.
Mike Edwards still has a long way to go with his budget. With the skills he
learned in chapter 1, he was able to create a dashboard on the first round of
analysis. For the next stage of the report, he needs to involve other members
of his budget team. Depending on the feedback he receives from his
colleagues, he will be able to advance to the next stage with his budget. This
chapter will you, the reader, how Mike was able to share his dashboard with
his colleague using the in-built features of Microsoft Power BI.
NB: The share feature is only available on paid accounts, users with free
accounts will not be able to share access to a dashboard.
Clicking the share button generates a dialog box. The dialog box
has two tabs, one is named Share and the other Access. The
Access tab shows the people that already have access to the
dashboard. When Mike clicked on the tab, only his name was on
the list, and it was tagged “Owner.” On the Share tab, he saw an
input box for the email address of the recipient. Under the email
box, he saw another input box for an optional message to the
recipient. Below both boxes were the permission boxes, which
allows him to choose the activities the recipient of the access can
perform. The three permissions available include
Permission to share the report to other users
Permission to create new content using your
datasets (this permission was not included
before, it came with the latest update on Power
BI)
Permission to receive email notification about
details of the report.
The type of activities the user can perform is left to you, in this case, Mike.
Mike inputs Perri’s email address as [email protected].
Power BI did not allow him to input the address in full before it
automatically generated Perri’s email address. This is because
Perri is a registered member of Enigma industries, and Power BI
has access to the email addresses of all workers in the domain.
NB: It is possible to share the report with people that are not members of the
organization, and it is also possible to share with more than one person at a
time.
Mike added an additional message to inform Perri about the
progress of the report and the type of feedback he needs on the
report.
The last item on the Share tab is the URL (website link) of the
report.
Perri will receive an email containing the link and message from Mike. If
Perri is already a user on Power BI, she will be directed directly to the report,
but if she is not a user, she will have to register and create an account to gain
access to the report.
NB: You can also send the reports to users outside your organization with the
same steps listed above. Power BI will recognize the fact that company email
does not belong to your organization and will point it out to you. Ignore the
warning and continue with the process. Once the user receives the email, he/
she will be able to access the report.
Another way to share your contents with users outside your organization is to
publish the report to the web. The publish button is directly above the share
button. Click it and publish the report on the web. This feature converts the
report into a web link. The major disadvantage of this method is that anyone
with a working internet connection and the address of the link can access it.
There will be no restriction for the viewing of the report. This method
involves the exposure of delicate company information to the general public,
so do not use this method unless your organization authorized the publishing
of this report.
NB: Only users with paid accounts can create workspaces, it’s not allowed on
free accounts.
You can restrict the activities of users on your workspace by placing them in
the right category. For example, Mike wants all 20 team members to be able
to edit the report, hence he registered all the team members in the contributor
category.
After signing in, he was able to access all the visuals he created on his
dashboard. He was able to access the report because he was already signed in
on his Power BI Desktop. It’s possible to use the desktop version without
signing in, but as it says on the splash screen when you first launch the
desktop app, to get the most out of the software you have to sign in.
The mobile reports are not editable and have no interactive functions.
Basically, the app is only good for viewing and accessing the reports on the
go.
Chapter Three:
Loading Data from Different Sources
Before you can create a report or perform analysis on Power BI, you need to
load your data into the software. The data may be from different sources and
exist in different formats. Whatever or wherever you get your data from, you
have to access it, restructure it, clean it up, and sometimes join separate data
from different sources together before you can create a data model for
dashboard and reports. The beauty of Power BI is that you can do all of this
on the Power BI Desktop without employing the use of other data structuring
tools and software.
Power BI Desktop will help you discover, load, clean, and modify your data,
that’s one of its area of specialty. With the app you will be able to achieve the
following;
Data discovery: Discover numerous data sources containing
possibly useful data. The sources may be from private or public
domains.
Data loading: Once you have selected the source of your data,
upload it to Power BI Desktop for restructuring and shaping.
Data modification: Adjust, filter, and clean the data until it is
presentable and workable.
Data shaping: Combine all the data you uploaded (if you
uploaded more than one) to create a unified data model.
In most cases, the four steps above are not usually carried out individually
and may be blended into a single process. It is possible that you may have
cleaned and structured the data before you loaded it into Power BI; in that
scenario, you don’t need to bother yourself with the process all over again.
NB: Power BI classifies Microsoft Access as a database source, but for this
book, we will treat it as a file, not some a database on some server.
The choice of the option to click on rests on your shoulders, but for the
purpose of explaining how to load .csv into Query Editor click “Edit.”
❖ On the Query Window, you will be able to add another source and
to perform all the necessary edits for the file. When you are done
editing, click “Close and Apply” on the Home ribbon. This will close
the Query window and take you back to the Power BI Desktop data
window.
NB: The process to upload a .txt (text) file is identical to that of CSV.
Though they have their little differences, they can be accessed in the same
manner.
Under the message, there are two buttons “Start” and “Cancel.” Click on Start
to begin the import process
❖ You will be able to see the progress of the importing process. Once
the process is completed, Power BI will display the summary of the
items imported. When you are done checking the items that
successfully imported, click Close to exit the summary dialog.
The table represents Access tables while the windows represent Access
queries.
Relational Databases
The difficulty you will face when trying to load a data file from a relational
database won’t be from Power BI, rather it will be from the Guardians of the
data on such databases. Once you can get through the logins, special
passwords, and other security roadblocks, loading the data into the Power BI
Desktop becomes easy. This book will not be able to teach you how to pass
the guardians, but it will be able to teach you what to do when you pass the
guardians.
The various relational database Power BI Desktop can link you to are listed
below;
➢ SQL Server database
➢ Access database (you already know this, it has been covered in the
chapter)
➢ IBM DB2 database
➢ Oracle Database
➢ IBM Informix database
➢ IBM Netezza
➢ MySQL database
➢ PostgreSQL database
➢ SAP HANA database
➢ Sybase database
➢ Teradata database
➢ Amazon Redshift
➢ Impala
➢ ODBC data sources
➢ OLE data source
You will be able to connect to all the databases listed above and import
records of the data tables that you are permitted to access.
Loading your data into Power BI Desktop is just the beginning of your work.
After loading the data, you have to modify, clean, and filter it to make sure it
is ready to be used. This chapter will cover the numerous methods and
techniques you can use to transform your data. The numerous methods and
process can be grouped into four major categories. The categories do not, in
any way, define the order the tweaking or editing process goes. The
categories are just meant to intensify your understanding of the process.
The four ribbons at the top of the screen and the File menu. The
ribbons are named
– Transform
– Add Column
– View
– Home
Query list pane which contains the all the files (queries) added
to the Query Editor. It is found at the left side of the screen.
The status bar is found at the bottom right corner of the screen.
It shows the number of columns and rows in the query, and it
also shows the date the query was loaded into the Query Editor.
The contents of the cell are shown at the bottom left corner of
the screen. It states the exact number of rows and column
present in the query.
Applied Steps
Beneath the Properties menu on the Query Settings pane, there is a menu
called Applied Steps. The menu contains a list of all the possible
transformations that can be performed on a query. As a transformation
process is carried out, the menu automatically checks the checkbox beside the
performed transformation. It is able to detect every little step performed on a
query and records it for future purposes. It is a form of recorder that shows
you all you’ve done on the query.
When you click on a box in the Applied Steps menu, the queries displayed in
the Data window will change to reflect the effect of the particular
transformation the box covers. Each step you perform on the query is named,
this allows you to trail your every step in the modification process. The
manner in which the steps are named will be discussed when the possible
transformation steps are explained later in the book.
Home
Below are the description and functions of all the button present on the Home
ribbon as of the last update on August 2019. The ribbons are arranged
according to the way they are located on the ribbon.
Buttons Functions
Close & This is the first button on the Home ribbon.
Apply Selecting this button will save all the
changes performed on the query and close
the Query Editor window. You should only
use this button when you are done with the
transformation process.
New Source This button allows you to add more queries
to the one present i the window
Recent This button lists all the queries you have
Source edited on the window recently. It also
allows you to open them again in a separate
window different from the one you're on.
Buttons Functions
Enter Data This allows you to create your own
custom-made data in the Query Editor
Data Source This gives you control over the data
Settings sources already connected to the Query
Editor
Manage Parameters Grants you access to modify the
parameters defined for the query file
Refresh Preview This performs a refresh on the sample
query
Properties Shows the basic properties of the query
file, such as the size, the name of the file,
and the date it was created.
Advanced Editor Shows the editor of the M language used
in data modeling
Manage Allows you to copy, delete or cite a
query
Choose Columns Gives you the power to select which
columns to retain among all the columns
available in a query
Replace Values This button carries out the search and replace
operation in the Query Editor. It only
changes the values specified in the search
box to the values in the replace box. It won’t
affect the other values that are not present in
the search box.
Merge Queries This allows you to combine two or more
queries together. It joins the columns and
adds the values to make a single query.
Append Queries This allows you to add the data from a
previous query to the query opened in the
Query Editor. This does not join the column
or adds the values as Merge Queries does.
Combine Files Joins and combine the data from multiple
files into a single table. This is possible as
long as the files are of the same format, have
the same number of columns, and have the
same type of data in each column. This is
different from the Append query because it
does not deal with previous queries, it deals
with files.
Transform
The transform is the richest of the ribbons in terms of features and functions.
It has about 32 buttons on it, and they all have different functions. The
buttons on the transform ribbon can be classified into seven major categories,
they are;
❖ The Table Transformation Buttons: These are the buttons in charge
of the transformation of a table as a whole. They include:
Buttons Functions
Group By This button can also be found on the Home
ribbon. It assembles the columns into
categories based on the contents of the
columns.
Use First Rows as This is also present on the Home ribbon. It
Headers grants you the ability to convert the
function of the first row in a column. The
first row stops being a simple row and
becomes the title of the entire column. As
you can see, this affects the table as a
whole. That’s the reason why this button is
in this category.
Transpose This button interchanges the directions of
the rows and columns. With this button, the
rows become columns, and the columns
become rows.
Reverse Rows This button interchanges the order of a
table. The bottom rows become the top
rows, and the top rows become the bottom.
While this might look confusing, the
interchange occurs in a specific order, the
last become the first, and the first becomes
the last. The remaining rows follow that
order.
Count Rows This performs a count operation on the
table and automatically replace the data in
a row with the number the row falls on in
the table.
Buttons Functions
Data Type With this button, you can select the type of
data present in each column. It could be
text or numbers.
Detect Data Type This automatically detects the data type
present in each column and uses it to
determine the appropriate data type to
apply to the column.
Rename This allows you to change the name of any
column in the query.
Replace Values This button performs the same function as
the one on the Home button. It carries out
the search and replace operation. It changes
the values specified in the search box to the
values in the replace box. It won’t affect
the other values that are not present in the
search box.
Fill Copies the content of an entire cell and
dumps it into an empty column. You can
decide the order it copies the content, it
may be from above or from below.
Pivot Column This button converts the contents of a
column into the titles of other columns.
This means that each row of a particular
becomes the title of different columns.
Unpivot Columns Performs the opposite of what the Pivot
Column button does. It takes the titles of
each column in the query and converts it to
rows in a single column, while the data
present in the columns are merged to
become a single column. At the end of the
day, two columns are formed- the column
for all the titles and the column for the
data.
Move This button can change the position of a
column
Convert to List When clicked the button will convert all
the columns in the queries to a list
Buttons Functions
Split Column Divides a single column in the query into
other columns after a fulfilling a particular
requirement
Format Formats the text in the columns.
Regularizes the use of lowercase,
uppercase, and the capitalization of the
text. It also removes excess space in the
columns.
Merge Columns This button performs the opposite of what
the Split Column button does. It joins two
or more columns together to form a single
column. It separates the data in the column
by placing them on different lines.
Extract The function of this button is quite
complicated. In a way, it limits the number
of characters that can exist in a column.
After clicking the button, you must specify
how many characters should exist in the
column. With the button, you can also set a
condition that requires each cell in each
column begins with a specific character
and replace the data in a column with a
defined subset of data.
Parse This button converts the contents of a
column into a .json, .xml or .txt format
document.
Buttons Functions
Statistics This performs statistical operations on the values
in the columns. The possible operations include
the calculating of the total sum of the values, the
mean of the values, the median, pinpointing the
largest value, the smallest value, calculating the
Standard Deviation, performing a count of all the
values in the column.
Standards This button also performs calculations on the
values in a column, but unlike Statistics Button
the operations performed here are rather basic. It
is used to calculate the addition, subtraction,
division, multiplication, integer division, and
modulus of the values in a column.
Scientific This is also another button that performs
calculations. The calculations here are scientific.
Calculations like finding the Square, Raise-to-
power, Cube, Square root, Exponent, Factorial,
and Logarithm of values in a cell.
Trigonometry Performs trigonometric operations like finding the
Cosine, Sine, Tangent values of each row in a
column.
Rounding This button approximates the values of data in a
column. It can either round it up or down
depending on the factor specified.
Information Tests condition of data in a column. The possible
results are Even, Odd, Positive, and Negative.
Buttons Functions
Date This button only works when the values
involved are dates. This could be values
stating the day, month, or year. It isolates
the date element from others in the column.
Time This button only works when the values
involved are related to time. This could be
values stating the hour minute, seconds, or
nanoseconds. It isolates the time element
from others in the column.
Duration This button takes account of two values
and measures the duration, be it in minutes
or days. Before this operation can work,
the Editor has to recognize the values in the
columns as dates and time.
Buttons Functions
Expand This button allows you to combine two identical
queries together. It joins the columns and adds the
values to make a single query.
Aggregate This button allows you to sum the values of the
two queries together. Basically, it performs an
expanded function of the Standards button. It adds
the numeric values in the columns of two queries
and presents it in the current query.
Extract Values This button converts the values in a column to text
and extracts it.
Add Columns
This ribbon does not exist just for you to be able to add columns to a query, it
can break a single column into multiple columns, and it can add new columns
that contain information on date and calculations from existing columns in a
query. The Add column ribbon is divided into four categories, namely:
❖ The inserted column buttons: These buttons are in charge of
adding new columns to a query, they include:
Buttons Functions
Column From This button allows you to select an existing
Examples column as the sample of how the new
column to be created should be. After
clicking the button, you will have to select
the sample column to begin the process.
Custom Column This button creates a new column whose
contents are custom made from existing
columns. The new column is created with a
formula that uses variables from existing
columns.
Invoke Custom Using this button will require the
Function knowledge of “M” language. After clicking
the button, an input box will be generated
for the code of the language. When you are
done with the code, the interpreter of
Power BI Desktop will run the code and
apply it to the necessary part of the query.
Conditional This button creates a column based on an
Column existing column fulfilling a particular
condition. When a column fulfills the
requirements, interpreted values from the
column will be added to the new column.
Index Column This button creates an index column to
identify the existing rows. The index
column numbers each row in the query
with a unique number or roman numeral.
Duplicate The function of this button is pretty basic.
Column It merely duplicates the contents of a
column.
❖ The text column buttons: The functions of the buttons here are
similar to the “Text transformation tool” in the Transform Ribbon.
The buttons present in this category are:
Buttons Functions
Format Formats the text in the columns. Regularizes the
use of lowercase, uppercase, and the capitalization
of the text. It also removes excess space in the
columns.
Merge Columns This button joins two or more columns together to
form a single column. It separates the data in the
column by placing them on different lines.
Extract The function of this button is quite complicated.
In a way, it limits the number of characters that
can exist in a column. After clicking the button,
you must specify how many characters should
exist in the column. With the button, you can also
set a condition that requires each cell in each
column begins with a specific character and
replace the data in a column with a defined subset
of data.
Parse This button converts the contents of a column into
a .json, .xml or .txt format document.
Buttons Functions
Statistics This performs statistical operations on the values
in the columns. The possible operations include
the calculating of the total sum of the values, the
mean of the values, the median, pinpointing the
largest value, the smallest value, calculating the
Standard Deviation, performing a count of all the
values in the column.
Standards This button also performs calculations on the
values in a column, but unlike Statistics Button
the operations performed here are rather basic. It
is used to calculate the addition, subtraction,
division, multiplication, integer division, and
modulus of the values in a column.
Scientific This is also another button that performs
calculations. The calculations here are scientific.
Calculations like finding the Square, Raise-to-
power, Cube, Square root, Exponent, Factorial,
and Logarithm of values in a cell.
Trigonometry Performs trigonometric operations like finding the
Cosine, Sine, Tangent values of each row in a
column.
Rounding This button approximates the values of data in a
column. It can either round it up or down
depending on the factor specified.
Information Tests condition of data in a column. The possible
results are Even, Odd, Positive, and Negative.
❖ Data and time column buttons: Buttons in this category deal with
the columns that contain details on the time and date of an activity.
The buttons include:
Buttons Functions
Date This button only works when the values
involved are dates. This could be values
stating the day, month, or year. It isolates
the date element from others in the column.
Time This button only works when the values
involved are related to time. This could be
values stating the hour minute, seconds, or
nanoseconds. It isolates the time element
from others in the column.
Duration This button takes account of two values
and measures the duration, be it in minutes
or days. Before this operation can work,
the Editor has to recognize the values in the
columns as dates and time.
View
View is the last column in the Query Editor ribbon but not the least used.
While the significant transformation actions take place in the other ribbons,
the view ribbon is used to monitor the appearance of queries in the Query
Editor. The buttons on the ribbon include:
Buttons Functions
Query Settings This button allows you to choose whether the
Query Settings column should be visible or not.
The Query Settings column appear at the right
side of the Query Editor window, and one of the
items on it is the Applied Steps list.
Formula bar This is not really a button, it’s more of a
checkbox. The checkbox allows you to choose
whether or not the formula bar should appear at
the top of the data window. The formula bar is the
input box where the M language for coding is
written.
Monospaced This is also a checkbox, not a button. It is used to
display the text in the query in a monospaced font
(Courier).
Show Whitespace This is the third checkbox in this ribbon. It allows
you to decide whether you want to see the
whitespace present in the query or not. This
checkbox is always clicked by default, if it’s not
what you want, you have to turn it off.
Go to Column This button allows you to move your cursor to a
particular column in the query. It lists the columns
available, you can go to the column by clicking on
it. It’s a very fast method of shuffling between
columns in queries with large contents.
Always Allow This checkbox allows you to turn on
parameterization.
Advanced Editor This button generates an Advanced Editor dialog
box which shows the codes of the transformation
steps performed on the query.
Query Dependencies This button shows links and dependencies of the
query in the Query Editor.
Click on the direction you want the column to move, keep clicking until it
reaches your desired position.
NB: The name of this process in the Applied Steps column is Reordered
Columns.
The custom option lets you create a unique separator that is different from the
ones present on the menu. When you click the custom option, an input box
will be generated, and you will be asked to type in the character you want to
use as the separator.
The action generates an item on the Applied Steps column. The
item is named Merged Columns.
What you pick will determine the type of dialog box that will be generated.
1. If you select Keep Top Rows, a Keep Top Rows dialog box will
be generated. In the dialog box, you will see a box, which
allows you to input the number of rows at the top you want to
keep. This means that if you input 10 in the box, only the top
ten rows will be kept.
_ When you are done, click the OK button at the bottom of the
box to finish the process.
_ An item will be generated on the Applied Steps column, the
item will be named Kept First Rows.
2. Selecting the Keep Bottom Rows option will generate a Keep
Bottom Rows dialog box. In the input box, you can type the
number of rows at the bottom you want to keep.
_ When you are done, click the OK button at the bottom of the
box to finish the process.
_ Immediately an item will be generated on the Applied Steps
column, the item will be named Kept Last Rows.
3. The last option is the Keep Range of Rows option. Selecting
that option will generate a Keep Range of Rows dialog box.
There are two boxes in the dialog box, the First-row box and the
Number of rows box.
_ In the First-row box, input the index number of the first row
you want to keep. This is where the counting will start from.
_ In the Number of rows box, type in the number of rows you
want to keep. The number here starts counting from the row
mentioned in the First-rows box. This means if you input 25
in the First-row box and 50 in the Number of rows box, the
rows 1 – 24 will be deleted, 25 – 74 will be kept, and 75
downwards will be deleted.
_ When you are done, click the OK button at the bottom of the
box to finish the process.
_ An item will be generated on the Applied Steps column, the
item will be named Kept Range of Rows.
Ignore the Keep Duplicates and Keep Error buttons, for now, click on any of
the other options on the menu. It depends on the position of the rows you
want to delete. For Remove Bottom Rows and Remove Top Rows, the dialog
box generated is identical to that of the Keep Top Rows and Keep Bottom
Rows dialog box. Just input the numbers you want to remove then end the
process with the OK button. The item generated in the Applied Steps column
will be named Removed Top Rows and Removed Bottom Rows respectively.
For Remove Alternate Rows, the dialog box generated is very different from
the other options. There are three input boxes in the dialog
First row to remove
Number of rows to remove
How many rows to keep.
Clicking this option is tricky, and it should only be used when you want to
create a new set of data from the original query. To use the alternate row
option;
_ Input the index number of the first row you want to keep in
the first box. For example, 10.
_ Then input the number of rows you want the editor to remove
after the first row mentioned in the box above. For example,
2.
_ Finally, type in the number of rows you want to keep to form
a new query. For example, 10.
The editor will interpret the instructions given above as a command to alter
the query to contain only ten rows. It will take the tenth row as the first row,
delete the next 2 rows after the tenth row, save the original thirteenth row
(add it as the second row in the altered query), and continue the process of
deleting two rows then saving the third until a total amount of ten news rows
are created.
Now you can see the reason why the alternate rows option is a tricky process.
The new rows formed will be totally different from the original rows in the
query. Only use this option when you are totally sure of what the process will
achieve.
NB: When the Alternate rows are created, the step will be named as Removed
Alternate Rows in the Applied Steps column.
As it was said above, the filter feature in Power BI is a very powerful tool. It
can even weed out air if you set the right parameters. That was a joke!
How to Save all the Changes made in the Query Editor
You can save the changes made in the Query Editor at any time, even when
you are not done with the transformation process. To save the changes made,
carry out the following steps;
❖ Click on the File menu at the left edge of the ribbon at the top of the
Query Editor.
❖ On the menu generated, click the Save Option. This will generate a
dialog box with three buttons
Apply
Apply Later
Cancel.
At this point, you have to decide whether or not the changes you made in the
Query Editor should be applied to the original data file imported into the
Power BI Desktop. Selecting the Apply option will do just that, it will apply
the changes made in the Query Editor to the original data file.
The Apply later option will save the changes made to the data file in the
Query Editor, but it won’t change the original file in the Power BI Desktop.
Doing this only saves the changes made to the data file in Query Editor,
leaving the original data file in its untouched state.
The Cancel option cancels the Save action you just carried out. Choose the
option that serves your purpose best.
How to Exit the Query Editor
You already learned how to exit the Query Editor in Chapter 3, but that was
just the basic way of exiting the Editor. There are more options that apply
when leaving the Query Editor. To close the Query Editor carry out the
following steps;
❖ Click the first button on the Home ribbon at the top of the Query
Editor. This button is called the Close & Apply button. It will
immediately update the original data file with all the transformations
that took place in the Query Editor and exit to the Power BI Desktop
window.
❖ If you want to have other options, click on the small triangle below
the Close & Apply button. This will generate a pop-up menu with
two options.
Apply
Close
The Apply option will perform the same activities as the Close & Apply
button.
The Close option will close the Query Editor without applying the changes
made in the editor to the original data file. It is best to save the transformation
made in the Query Editor before choosing the option to prevent loss of data.
When you click the Close option, a small notification box will be generated
at the top of the Power BI Desktop data window, imploring you to apply the
changes made in the Query Editor.
The Query Editor is a very powerful tool for editing in the Power BI Desktop,
not all users know how to handle and perform operations with the tool. But
for those skilled in using the tool, and for you reading this book (this chapter
to be precise), cleaning, filtering, modifying, and transforming your raw data
file won’t be so difficult. Once you know how to edit your data in the Query
Editor, any problems that may occur during the creation of reports will not be
from incorrect or improperly structured data. Not all the buttons or features
were explained in this chapter, just the basic and popular editing steps carried
out with the Query Editor were explained. With practice, you will be able to
perform any transformation you want with the tool.
Chapter Five:
Data Models
Establishing the relationships between tables is the most basic aspect of data
modeling. You must ensure that your Power BI desktop can derive the
relationship between data on one table and another to get an accurate and
precise result.
N.B- Data modeling can only be done when the data has been inputted into
the Power BI desktop model, i.e., any data changes that occur in the Query
editor must be applied before returning to the Power Desktop BI to prevent
inaccurate results.
Before you start creating your own data model, it is important to get familiar
with the tools that will make the process easy to navigate after running the
Power BI Desktop. To achieve this;
Import all the queries to be used.
Switch to the Data View where all tables are visible by clicking
on the Data view icon on the left side of the window.
The Data View window is very similar to the Query Editor window, but there
are some major differences between them. One of them is that only a sample
of your data can be seen in Query Editor while all the dataset are made
available in Data View once it has been imported into the data model.
Another difference between them is that in Data view, you are working with
the entire dataset and modifications are made in line with the dashboard
requirement and specification. A major similarity is that they can both be
used to create calculated columns.
N.B- Always remember that Query Editor is for searching, clarifying, and
merging up while Data View is for enhancing and computing metrics in your
data model. Also, note that you have to close your Query Editor before
modeling your data.
Defining Data Types
There are nine different data types available to you on the Power BI desktop.
When you transfer files from an external source, the Power BI desktop will
try to change it to fit one of the nine data types. The nine different data are
listed below with their description:
NB: When using fixed decimal numbers, it is easier to avoid the overflow of
calculation errors that occur when using an ordinary decimal number. Also
using decimal numbers creates additional storage.
Exploiting Tables
After you have successfully imported and transformed your data, your next
plan should be to exploit and manipulate the tables. Tables will be used in
place of data because it is mostly the result generated when data are
transformed in the Query Editor. Manipulating tables involves the following:
➢ How to rename a table
➢ How to delete a table
➢ How to rename a column
➢ How to delete a column
➢ Setting width to a column
How to Rename a Table
Imagine you don’t feel comfortable with the name of a particular table that
has successfully been transformed and imported from the Query Editor, and
you wish to change or modify it to another, there are a series of steps to be
taken to achieve this;
❖ Go to the field list which is on the right side of the Power BI
Desktop window, there you will see the name of the table listed.
❖ Right-click on the name, this will generate a menu.
❖ On the menu, click on rename.
❖ Input the new name or modify the former name
❖ Press enter
Remember that Table is the result generated from the transformation of data
by the query, so changing the name of a table will also change the name of
the query
Creating Hierarchies
Creating hierarchies is important in the organization of data, it helps you to
create a structure for your work. This structure helps to understand better the
information you are trying to get across. When creating hierarchies, the
following steps are to be taken;
❖ Switch your Power BI desktop to report view
❖ Click on the stock table
❖ This will take you to a field, right-click on it. In the new hierarchy,
this will be the top-level element.
❖ Click on new hierarchy (make hierarchy will appear which consists
of Make field serving as the top-level element).
❖ The model Field is then dragged to the newly created hierarchy title.
Then you are done creating your hierarchy. This can then be used to create a
table by dragging it to the report canvas where multiple elements that make
up the canvas is put into use. This gives you access to the data in any visual.
They also make starting material for drill-down charts and matrices.
Renaming and deleting of any level in the hierarchy or the hierarchy itself is
also possible if you are not comfortable with it.
Relationship View
Relationship view allows you to view your entire dataset as a whole without
bordering you with the details. It gives an overview of your entire data tables,
Also you can view those tables that are already joined together. Power BI
tries to derive any possible relationship existing between the relationships
yourself. You can view your data in the relationship view by simply clicking
on the relationship view button at the left of the Power BI desktop. The
relationship view also helps in maximizing and minimizing tables. This can
be carried out by clicking the maximizing or minimizing button at the right of
the table name tables and creates this relationship automatically. It saves you
time and effort.
Managing Relationships
Learning how to manage relationships is crucial, especially if you want to
alter a field that serves as the foundation of a relationship. This is also useful
when you are trying to create or delete several relationships at the same time.
The process of creating and deleting several relationships is similar to those
discussed earlier. Managing a relationship can be described as the key to
creating effective and operative data model. To manage a relationship, you
have to:
❖ Click on the Manage Relationship button on the home ribbon.
A manage relationship dialog box will appear.
❖ Select the relationship you want to modify
❖ Double click on the relationship and select edit, this will bring
out the edit dialog
❖ Modify the relationship.
You also have the option of deactivating relationships. This occurs when you
no longer want a relationship to exist between two tables, and you don’t want
to delete it. Go to the manage relationship dialog, unselect the table in the
active box. The same process applies for reactivating a relationship.
However, the edit relationship dialog has an advanced option that might be
useful on some occasions, they are Cardinality and cross filter direction.
Cardinality helps you to outline the number of column in a table that is
associated with a similar column in the joined table. Cross filter directions
define whether a filter can be used for all the tables in a related group of
tables or in one particular table where the aggregation is carried out.
NB: If a set of joined tables are deleted, reimporting the tables will not bring
back the created relationship unless the joining are also reimported, i.e., once
a set of Joined table is deleted, Power BI Desktop will not remember the
relationship between them, such that any relationship that exists between
them has to be created manually.
Classifying Data
The dashboard is made up of hyperlinks, facts, figure, and geographical data.
A human can invariably recognize hyperlinks, but that is not always the case
for the Power BI. So to make your work easier, you have to classify the
column that house these types of data. For example, if you want a table that
will contain cities as the data source;
❖ Choose a city table in the field list
❖ Select the column containing the city name (this will be
highlighted).
❖ Select the box to the right of the data category button, a
context menu will appear
❖ Select a city from the menu
There are different data category options to pick from when classifying data.
Few of these categories are listed below:
➢ Uncategorized: This encompasses all data that are not involved
in the creation of mapping or hyperlinks.
➢ City: Indicates a city for creating maps
➢ Web URL: Specifies a URL used for hyperlinks
➢ Barcodes: This shows the fields containing the barcodes
There are also several other data category options apart from the once above,
such as country, continent, place, latitude, postal code, image URL, state,
province, longitude, etc. They are all used for creating mappings.
Even though you do not specify the data, the Power BI can still create maps
in the Dashboard, the downside of this is that the result will have a slim
chance of being a success. Nevertheless, if you specify that a column holds a
particular type of data, this can be avoided.
The Power BI desktop also has a wide range of currency format to choose
from if the data you are dealing with involves currency. You just need to
select the one you will be working with. The series of steps below show you
how to do that;
At the right of the currency icon, there is a downward-facing
triangle, click on it, it will bring out a variety of format.
Choose your currency symbol of choice.
At a point, the columns might be too much and clutter your work. When this
happens, you will need to hide some of the columns that are not relevant to
your analysis. This helps in the clarification of your work should a new user
want to use the data created by you, because it will eliminate the confusion of
seeing so many columns and guarantee that only the important data are
available.
When you want to hide a table or file, all you need to do is
❖ Select the table you want to conceal
❖ On the popup menu, go to report view and click hide
Once you are done with the process, the table will be hidden from view, and
this achieves your goal of reducing the clutter in your work. You are now left
with essential data needed for your analysis.
Types of Calculation
When your imported data contains all that is needed to create your
visualization, Power BI will make your life much easier. But this is not
always the case, there is still a metric to be calculated or added to tables
leading to the extension of data. A tool like Power BI desktop requires just
the addition of all metrics both calculated and imported from the source to the
dataset and not the output. The probability of an error being in your work is
reduced. Components that will be of important use to your dashboard are also
created when creating DAX metrics, the components include;
➢ Addition of components used in filtering visualizations
➢ Creation of component used in the classification of data, e.g.,
grouping
➢ Creation of derived metrics that will be seen in the
visualization
➢ Creation of new metrics that are based on the existing metrics
➢ Adding specific calculations of your own
➢ Creating order and rank for your Data
➢ Addition of weightings to value
➢ Addition of the new column to a dataset
Creating and adding a new column to a dataset is one of the two ways a
dataset can be extended. Reasons why you might want to extend your current
dataset:
Connecting the data from two already existing column to give a
new column
When carrying out fundamental calculations such as addition and
subtraction in every row of a table for more than one column
When you extract the part of a data in one column to another
column where you need it
When you extract from the date column, the date element to a
new column
When you want to extract a part of data from a column to a new
column
There are still several other reasons for extending a dataset, but the important
thing is that at a point, the need will arise to extend a current dataset. There
are several ways of extending a dataset, and these ways are very similar to
that of Excel. The knowledge of extending dataset is based on that of Excel,
i.e., the function, extension techniques, and the way it is designed all follow
the same pattern as excel. You should also note that when a formula whether
derived or existing in the Power BI, is added from the start to a column, and a
new column is created, this formula also applies to the new column. The data
can only be recalculated when you refresh your source data.
In the field list, new columns are always designated with a small Fx icon so
they can be distinguished from other fields.
With what you have read in the chapters of the book, you can see that it really
is a comprehensive beginner guide for learning the basics of Power BI. What
is in this book can help you create data models, reports, and visualizations for
your business or organization. If you read the tutorials and instructions given
in the book thoroughly, you will have an idea of how to operate and use
every feature Power BI boasts of. However, if you want to dig deeper into
what Power BI has to offer, you will need an advanced guide that will take
you farther into the Business Intelligence tool. Advanced guide books will
cover more about the DAX language and how to use it to create and edit data
models on Power BI.
Resources
www.techtarget.com
Adam Aspin (2018), Pro Power BI Desktop: Interactive data analysis and
visualization for the desktop. Apress
Johansen A. (2016), Python: The Ultimate Beginner's Guide! CreateSpace
Independent Publishing Platform.
Alberto Ferrari and Marco Russo (2016), Introducing Microsoft Power BI.
Microsoft Press.
Alberto Ferrari and Marco Russo (2017), Analyzing Data with Microsoft
Power BI and Power Pivot for Excel. Microsoft Press.
Brett Powell (2018), Mastering Microsoft Power BI. Microsoft Press.
Dan Clark (2016), Beginning Power BI with Excel 2013: Self-Service
Business Intelligence Using Power Pivot, Power View, Power Query,
and Power Map. Apress.
Power BI
DANIEL JONES
Introduction
Data Processing
When we need to present a report at a meeting or do some kind of analysis, it
is not uncommon to search for the data in various sources such as
spreadsheets, text files, databases, or reports exported from systems. Then
you have to start processing that data. When done in Excel, for example, this
work is done by copying from here and pasting their several formulas in
Excel to extract a part of the text, convert the data correctly, macro in VBA to
remove unwanted rows, join information from one report with another to this
information
Instead of filtering by a manually typed text, we will choose the filter by a
parameter. Note that we could have created a new parameter in this window,
too, by choosing the last option. Then, just select the parameter in the list
next to it and click OK.
The column will be immediately filtered for the value that is stored in the
Country parameter. Note the formula in Power Query: each [Country] =
Country, i.e., each item in the Country column that matches the text entered
in the Country parameter.
We can modify the current parameter by clicking on it and writing, for
example, "CA" in the Current Value box. Afterward, just press Enter on the
keyboard to save this new text in the parameter.
Created by the SSAS team of experts, with the Power Pivot, it is possible to
analyze more than 20 million lines inside Excel, something completely
impossible to execute previously. And all this, without harming performance,
by storing the data and calculations in computer memory. Donald Farmer
(2010), one of the top product managers at the time of Power Pivot
development, considers the technology to be a new type of Analysis Service
designed to put the power of SSAS calculation in the hands of an Excel user.
Due to the popularity of Excel and the robustness of a solution used in SSAS,
the DAX language was quickly spread and accepted after the release of
Power BI. Its functions are classified into ten categories. Between them:
Date and Time
Time Intelligence
Filter
Information
Logic
Mathematics and Trigonometry
Hierarchy
Statistics
Text
Other
The tables are stored using xVelocity in-memory technology, also called
VertiPaq, which compresses the data in the best possible compression
according to its variation, redundancy, classification, and type. Some
important features should be observed in Power BI:
The tables must have different names in the same data model.
Columns within the same table must also have different names.
Columns in different tables may have the same names since their
address will be the table name + the column name.
Unlike the language M, in DAX, all objects are case-insensitive;
that is, DATE and Date are considered equal names.
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).
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.
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 eliminate unnecessary rows, you must press the “Remove rows” button on
the “Start” tab (remember that we are working in the Power Query window)
and choose the option “Remove upper rows.”
In the window that will open, we must indicate that we want to delete the top
2 rows (remember that we want to delete rows 1 and 2 that did not contain
data of interest).
You will be able to observe how the first two rows of the table have
disappeared and that in the right panel, the action “Upper rows removed” has
been added.
If you make a mistake by doing something, you can delete it by clicking on
the X or edit it if you click on the gearwheel.
The next step is to correctly assign the headings, which are now in row 1, as
can be seen in the following image.
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.
Transform Columns Into Rows
The correct way to work on the Power BI model is that the same data can
only appear in one column. This rule is not met in our table, as the number of
inhabitants appears in column 1960, 1961, 1962, etc.
To transform the columns into one with the year and another with the number
of inhabitants you must select all the columns of dates (from 1960 to 2018) as
you would in Excel, holding down the “Control” key and selecting them one
by one or selecting column 1960 and holding down the “Shift” key when
clicking on column 2018.
Once all the columns have been selected, you must click on the “Cancel
dynamization of the columns” option of the button with the same name found
on the “Transform” tab.
Our table will transform the columns into rows automatically and will have
one column with the years and another with the number of inhabitants
corresponding to that year.
The next step will be to rename the columns, "Attribute" as "Year" and
"Value" as "No. of inhabitants" by double-clicking on the column name.
After performing these actions, a new column will appear in the table with
the World Bank data, and you will have to press the button with the two
arrows.
In the pop-up menu, only the option "Common name" should be checked and
unchecked "Use the original column name as a prefix."
Once this is done, press the "Accept" button, and you will have the name of
the country in the table.
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.
The options offered are very wide, and deepening them requires a lot of time,
so in this section, we will focus on the creation of graphs from the data we
have prepared previously.
Calculations With Dax (Use Calculate)
During the transformation process, we have created a column with country
data on the world population, the active population, and the urban population.
If we want to calculate the total urban population, we cannot use a formula
that adds up the entire column “Number of inhabitants,” since we would also
be adding the active population and the total population. To solve this
situation, there is the CALCULATE function, which is one of the most useful
when learning Power BI is explained in this example.
To start, right-click on the “World Bank Data” table found in the “Fields”
section of Power BI Desktop and select “New measure” from the pop-up
menu.
You will notice that the formula bar has been enabled to write the DAX
function.
We will write a function that will add the number of inhabitants if the
“Indicator Name” column is equal to the “Urban population.” This will not
add the active population or the total population.
Type the following expression in the formula bar:
Urban population = CALCULATE (SUM ('World Bank Data'
[Number of inhabitants]); 'World Bank Data' [Indicator Name] =
»Urban population»)
This is what our function will do:
CALCULATE warns the system that we are going to perform a calculation
by applying a filter (we just want to add the urban population).
SUM ('World Bank Data' [Number of inhabitants]) will add the values of the
column “Number of inhabitants” in the “World Bank Data” table.
The 'World Bank Data' filter [Indicator Name] = »Urban population» forces
only the values of the urban population to be added, ignoring the rest.
When closing the last parenthesis, we finish the calculation.
You can repeat this same procedure to calculate the total population and the
active population. Here you can see the expressions you should write:
Active population = CALCULATE (SUM ('World Bank Data'
[Number of inhabitants]); 'World Bank Data' [Indicator Name] =
»Active population, total»)
Total population = CALCULATE (SUM ('World Bank Data'
[Number of inhabitants]); 'World Bank Data' [Indicator Name] =
»Population, total»)
At this point, you will have in the Power BI field selector the three measures
that we have created marked with the icon of a calculator.
Graphics
Now that we have the basic calculations, we are going to create the first
graphics in Power BI Desktop.
Click the left mouse button on the line chart icon, and an empty graphic will
appear inside the Power BI canvas.
Before continuing, be sure to select the graphic you just created and make it
wider to see it better.
The next step is to take the measurements we have created to the chart. Stop
it, and we must have selected the graph and click on the field of selection of
the measures we want to use and the year.
They will have a graphic similar to this on the screen, and you can enlarge it
by clicking on the “Focus mode” button.
The dates may appear untidy because the graph has been ordered according
to the number of inhabitants and not by year.
To order it correctly, click on the “More options” button on the graph and
choose the options sort by year and ascending order.
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:
Introduction to Power Pivot
At this point, we will focus on the Excel add-in, which allows business users
to create their own analytical models and populate them with information
from a variety of data sources, independent of the IT department. In addition,
a model created in Excel can be shared in SharePoint or imported from SSAS
(with the help of qualified from the IT department), reusing everything that
the business user has developed in Excel.
Power Pivot for Excel is an add-in for Excel that allows us to integrate and
structure in tables the information from various data sources, and this
information is stored in the files ". xlsx" with a high degree of compression,
and at the moment they are opened they are read and loaded completely into
memory, which allows for a speed of calculation not seen until now in Excel,
as well as the possibility of storing large quantities of rows, many millions of
rows, thus overcoming the limitations (approximately 1 million rows) and
slow speeds that we have when there are a large number of rows in traditional
Excel sheets.
To give you an idea of the high compression that can be achieved, let's take
an example with real data, made by SolidQ. We have a model with four
boards:
Clients 18,848 rows 29
columns
Date 2,191 rows 19
columns
Products 606 rows 36
columns
Sales 6,341,790 26
rows columns
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
General
Decimal Number
Whole Number
Currency
TRUE/FALSE
For data types Date, Date/Time, and Time you can choose from a variety of
formats, more or less extensive, to represent that date/time.
Currency symbol assignment. This and the following icons
behave in the same way as in traditional Excel sheets.
Display as a percentage, note that it multiplies the value stored in
Power Pivot by 100.
Format: format with a thousand separator.
Let's go a little deeper into the types of data. Each column is assigned a data
type, which by default is automatically assigned according to the data type of
each column of the origin, but you should review it manually, to improve it if
possible, and reassign a more appropriate data type if you consider it
appropriate and, of course, if it is compatible and allows you to store the
values obtained from the origin. By this, I mean that, for example, if you
have a column with customer names, you can't turn it into a type of numerical
data. These data type changes have to be done manually in Power Pivot once
the table and its columns have been created after the first import of the data
(which is when the data types are assigned).
You should take into account the following aspects in terms of data types and
format:
The type of data affects storage, while the format only affects the
display. You cannot assign data types that do not allow you to
store the values that the data in that column has.
Do not assign inconsistent formats for the chosen data type,
although in some cases, this is allowed. It doesn't make sense to
have a type of data
Integer' and in format to assign two decimals (although always
worth ".00" is confusing).
The format 'Currency' does not make conversions: 142.84?
Group of options 'Sort and Filter': these are options related to sorting and
filtering of the data.
A-Z: Sort in ascending order by the selected column.
Z-A: Sort down the column by choosing
Clear Sort: removes any sorting that we have enabled with the
previous options.
Clear All Filters: eliminates the established filters, leaving all
the rows of the table visible.
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.
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.
'Advanced' Menu
As a summary we show the way we have walked so far with what we have
seen on Power Pivot, to give you an idea of the road we still have to walk,
and that we will cover it in the section dedicated to the DAX Language:
So far we have studied how to perform most of the process, we know how to
create dimensional models and make the logical design, we know how to
perform ETL processes (extraction, transformation, and loading) using Power
Query and make the appropriate improvements to the model.
We still have to obtain external data from the Power Pivot itself and know the
DAX language to enrich the model. These points will be the ones we see
below.
What is DAX?
DAX (Data Analysis Expressions) is a language of expressions that we can
find inside Power Pivot, and it is based on formulas that allow defining
personalized calculations. It consists of a library of functions and operators
that can be combined to generate formulas and expressions. It is characterized
by its simplicity of syntax and its similarity to Excel formulas and has even
inherited many functions with the same name and functionality (except for
small variations in a few exceptions).
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:
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
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: DISTINCTCOUNT
The following table shows the syntax of these functions and a brief
description. For more details, you can see the product's help.
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
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:
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.
Since 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.
For the remaining columns to be created, we will continue to use the Custom
Column menu option, since in all cases, we will need to extract a substring
from the Individual column.
Attention to Upper and Lower Case in M
Now that we have begun to write M code, we must be cautious when creating
our expressions, due to the distinction between upper and lower case letters
that this language makes between its elements, such as reserved words,
function names, etc.
If for example, we try to create a new column with the following expression.
TEXT.Range ([Individual], 2, 3)
Having written the name of the TEXT function category in capital letters
instead of Text, which would be the correct form, we would get the error we
see in the following figure.
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.
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
=====================
Age
The age of the individual will be transferred to a column called AgeID
(Whole Number) obtained from positions 15, 16, and 17.
Age ID
=====================
TamMunnoverBirthID
=======================
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.
In 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.
In 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%20Server%20Analy
Power BI
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.
Data sources in the current file: this will have the list of all data sources
which have been connected in the current file.
Global permissions: this will have the list of all data sources which have
been connected previously in all the files.
Change Source
The below steps will show you how to change the source/ sources. Please
note that the ‘Change Source’ option is available only for the current file.
1. After selecting the source name, which you want to change for
the current file, Once you click on the ‘Change Source’ button at
the bottom left corner of the window.
2. Replace the old Source name ( System Identifier ) with the new
one and click on the ‘OK’ button.
3. If the new source which has been added is not connected
previously in your Power BI Desktop, then after replacing the
new source following the steps mentioned above, once you click
on the refresh button ( Home ribbon), a pop up window will
appear. Because you are connecting this particular data source
for the first time in your Power BI Desktop, you need to give the
credentials there.
Edit Permissions
In case of situations where:
1. password has been modified for a particular user or
2. (2) User needs to be changed to connect to a particular source.
Clear Permissions
The credentials to connect to a data source can be removed following the
below steps:
In the ‘Data Source Settings’ window, select the particular data source and hit
the ‘Clear Permissions’ button.
From the drop-down of ‘Clear Permissions’ button, you can choose:
(1) Clear Permissions: credentials will be removed only for the selected data
source
(2) Clear all permissions: credentials will be removed for all the data sources.
You can type your question and keep on refining it to reach to specific
answer that you want an answer for. Alternatively, you can also use the name
of the table that can help you to form a completely new question.
Step 2. Select from the displayed dropdown, or you can also start typing the
question of your own choice of question.
Step 3. While you are typing a question, Power BI Q&A selects the most
suitable visualization to show your answer; and this visualization would
change dynamically as you refine the question, as shown in the following
figures.
The question here is: total units of 2020 by month
The question here is modified to total units of 2020 by month by
manufacturer
Step 4. While you type your question, the Q&A feature searches for an
answer in any dataset, which is having a tile placed in its dashboard. If each
tile is from the Sales and Marketing Sample, the answer is going to come
from Sales and Marketing Sample. If there are tiles from Sales and
Marketing Sample and Other Dataset, then the Q&A feature will look for the
best answer present in both these datasets.
Please note: You need to be cautious if only one tile is present in the Sales
and Marketing Sample, and by chance, you are removing it from the
dashboard, the Q&A feature will not be having any access to Sales and
Marketing Sample.
Step 5. Once you are satisfied with the overall result, you can now pin the
visualization to any dashboard with the help of a pin icon present at the top
right corner. If you have not created the dashboard yourself, or it has been
shared with you from any other member, you are not allowed to pin the
visualization.
Step 6. You can also tell Power BI Q&A functionality the type of
visualization you want to view. If you noticed, the preceding graph is a bar
chart. If you want a line chart, you just need to add word line after your
query, and you will get the visualization changed to a line chart.
Strategies to Learn
Power BI Functions
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.
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.
TotalSalesbyDAX = SUM(FactInternetSales[SalesAmount]) +
SUM(FactResellerSales[SalesAmount])
Now drag the measure into value field of the card. And do some
formatting by using the format pane of card visualization.
This creates treemaps that show the sales made through the internet and
reseller in various product categories.
Publishing a Dashboard
Click on the publish icon, which is on the top right corner.
A sign-in dialogue box will appear where the Power Bi account
email id needs to be entered.
Give a password and click on sign in.
Select my workspace.
A dialogue box will appear, saying that the report is published.
Click on the report name; it will navigate to the Power BI portal.
Now the report in the portal will appear. Click on the icon pin
live page to create a dashboard for the report.
Give the name of the dashboard and click on pin live.
The dashboard view can be switched between the web view and
phone view.
Scheduling a Dashboard
Click on subscribe to receive the email.
A dialogue box will appear, saying that an email will be sent
whenever the data is updated. Click on save and close.
Now data refresh for AdventureWorks needs to be scheduled. Go
to AdventureWorks and select a scheduled refresh.
Install power bi personal gateway if the data source is on-premise
and mention the gateway connections and enter the credentials of
the data source.
Data refresh can be done daily or weekly and set time zone and
mention at what time the data needs to be refreshed if there is a
failure in data refresh a notification mail will be sent. Click on
apply.
As a data refresh is scheduled whenever the refresh happens, the
subscription will trigger an email to us.
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.
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.
Column_name Type
WorkYear Int
Workweek Nvarchar
USA Int
SNO Int
File Name = Trend.pbix
Slicer Tool will act as a filter tool. You have two-year values (2019 & 2020).
In the example, I selected the value 2019 from the slicer tool, which is
coming from Query1 Dataset. So, the designed report will also show only
2019 year values information.
Add a new value to the Trend Data table to see whether it is reflecting in the
Power BI Report or not.
SQL> Insert into [dbo].[TrendData] values(2019, 'SNO4', 140, 138, 123, 251,
106)
Close the Power BI Desktop file Trend.pbix and open again; you won’t see
the newly inserted ‘WW07’ values in the Power BI Desktop until you do a
“Refresh.”
Direct Query
It won’t copy/import any data to the Power BI Desktop.
Whenever a user wants to create/interact with a visualization, ‘Direct Query’
queries, only the underlying data from the DB. Meaning always you will
view the current data.
File Name = Trend_Direct.pbix
SQL> Insert into [dbo].[TrendData] values(2020, 'SNO5', 145, 213, 126, 174,
148)
Close the Power BI Desktop file Trend_Direct.pbix and open again, you can
see the newly inserted ‘WW07’ 2018 values in the Power BI Desktop without
a Refresh because Direct Query will always give us the current data from DB.
1. Suppose instead of pulling data from a single table; if you want
to join with some other table to get the result set, then you need
to right-click on the Dataset ‘Query1’ and select the ‘Edit Query’
option highlighted in the screen.
2. Double click on the Source option highlighted on the screen.
3. Database server connection popup will open, and you can modify
the query by joining with other tables and put the statement again
in the ‘SQL Statement’ window highlighted on the screen.
Note: While modifying the query statement, think you have already designed
the Power BI Desktop with some attributes, make sure that the same attribute
names must come again along with other new additional attributes (if any).
Otherwise, you will lose the design which you had already designed before.
Example: You designed the Power BI Desktop using (Work Year,
Workweek, USA, SNO) attributes while modifying the query to make sure
these attributes must come in the new query also otherwise, you will lose
design.
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.
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.
1st Tab - You set dynamic parameter values for the two datasets
“MissedRecords” & “MissedPercentage.”
2nd 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.
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.
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.
This is the way to know which dashboard you're pinning your visualization
into.
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.
You can identify a shared dashboard with you, by lock icon prefixed to the
dashboard name. To delete a dashboard, click Delete, following the same
steps as removing.
Create an Empty Dashboard
1. Click the plus sign that appears against the Dashboards heading
on the navigation pane.
2. Give a name for your new dashboard.
Your dashboard will be blank until you get some data. You can get data from
either of these options mentioned below:
Pin the answer(Visualization) from Q&A
Pin visualization from Reports
This is just a start in Power BI; there is still much more to come. So keep on
exploring and stay up to date with the information that matters to you most.
Power BI for
Report Generation and Mail
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.
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.
Document data source form fetches data from three services such as Service,
Query reference, and Custom query from AX and which can be displayed in
reports at the end.
Here you will create a new document data source based on the required data
from the related query.
Now that you have added an existing query of AOT “CustTable” as Query
reference as the data source type and Customer Details as description.
Once the required query is selected and added on document data source form
as above, go to browser/internet explorer and enter the URL of the AX Odata
query service. Make sure this URL is running and displaying the XML code
associated with it. This verifies the Q data query service is running fine from
the AX perspective without any issue.
One can verify against query wise AX Odata query service URL by running
it in the browser.
Once the AX Odata query service is successfully verified on IE, the next
stage will cover report design steps in Power BI Desktop as below.
Open Power BI Desktop. Now click on Get Data option. This will open a
screen which contains various available source data file supported by Power
BI.
As you need to get data from AX using query service, you will select Odata
Feed from the list and click on connect. On the next screen, it will ask to
provide the URL of the AX Odata query service.
Once URL is entered on clicking OK, it will fetch and display all the query
service registered in the AX document data source form.
Here you will select CustTable Odata feed as a data source. In the right side
window, one can preview the data populated from the query. Once the
required query is selected, click on the Load button.
Once data is loaded, it will appear in the Power BI report designer window.
Now, based on the selected visualization-basically report format like Table,
Matrix, Pie chart, BAR Chart- you can display the data in the report. Kindly
note here you can make various field related and report format related
changes in detail as and when required.
Once data is added, you can see it with a preview page.
Also, you can publish this report on the cloud if you have azure subscription
active, which is provided at an organization level.
Below are a few other types of reports created as a sample.
Pie chart report - Currency wise Amount.
Donut Chart report – Customer group-wise amount.
Administration/IT Administration/Services
2. From here, open the Web services page. This page contains base
web services.
3. By clicking the New button in the action page, you can create
new web service with object type: Page
4. Add the below details to the page to create the Web service.
You can use this application to create and design quick reports with various
gateways to get data. Directly you can access the SQL Server data into this
application to get data. Manipulate with data and get the expected result to
display in the report and design as required with the predefined graphs and
formats.
Once Done, Notice that you will get a Power Pivot option over the Excel
Tabs.
If you see carefully, you now have the option of Power Pivot with features
such as
a) Pivot Chart
b) Power Map
c) Power View
d) Power Query
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.
So this is how you can schedule data refreshing on the Power BI dashboard
automatically on a daily or weekly basis. This saves a lot of time and manual
effort.
Dynamic Row Level
Security in Power BI
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.
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
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.
Therefore, Row-Level Security is just a way to restrict the access of the user.
This can be achieved by applying filters at the row level.
Toggle Button and
Tooltip Features in Power BI
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.
To show the data labels turn the Data labels slider to On, then
in the Display units drop-down, select the Millions to show
the values as millions.
To show the data labels turn the Data labels slider to On, then
in the Display units drop-down, select the Millions to show
the values as millions.
Use Case: The customer wants to display different views on a page when you
click on a button and show multiple metrics on a single tile.
Feature Requirements:
1. Toggle between different visuals in a single page
2. Report Page Tooltip
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 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
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.
When you click on the below button, you will get the
tables.
When you click on the below button, you will get the
visualizations.
You need to turn on the Tooltip slider and then move to the
Page Information card. There you can mark the page as a
tooltip.
For visuals in the report, to auto-enable the tooltip to drag the
fields into the Tooltip fields bucket, so that the fields can be
specified for all the reports appearing in the tooltip.
When the mouse is hovering over the sections in the pie
chart, it shows the product type and gross profit in normal
visuals, as shown in the below image.
But with the tooltip configured visual, when the mouse is
hovering over the sections in the pie chart, it shows the
tooltip as Revenue and Planned revenue to that particular
product type, as shown in the below image.
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.
Publishing App
Go to Workspace -> The app workspace you created -> Click on Dashboards
Click on Publish App.
This will take you through certain steps:
1. Fill in Details, Content, and Access
2. And click on Finish to end publishing the app
This is the App Icon generated through App Workspace. On clicking the app
icon user can view the dashboard.
The end-user/business user can install the app from Microsoft AppSource, or
the admin/creator of the app can directly send the URL link to the app.
Updating the App
For any changes made to the dashboards in the Apps Workspace. The app
needs to be updated.
1. Modify the dashboard: You will have edit report option on the
top of the report to make any changes
2. In the app workspace, you will find the update app option.
3. Update all the options: Details, Content, and Access.
4. Click on Update App.
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
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.
There are three views found towards the left of the Power BI Desktop.
Report View is the View, which shows the actual representation of the data
based on the visualizations of the chart selected.
Data View depicts the data in table format. You can cross verify the data to
be mapped to the report. Intermediate changes are allowed to adjust the data
using the query editor window and need to refresh the data for the same to get
refreshed to the report. The below diagram depicts the sample data
Relationship View depicts the pictorial representation of the relationship
between columns.
The user can also Edit / Combine more than one table using query editor. The
query editor is used to shape and combine the data from multiple tables.
However, the original data source is not getting altered. Based on the
requirement, only the view of this data source is getting altered. This also has
an option of merging queries.
All data manipulation activities are carried out in the query editor. Suppose
the current data type of the column is decimal and need to convert to the
whole number just right-click the column header and select change type and
again select the whole number.
Finally, to apply the query Editor changes, click on the close & apply button
in the Home Ribbon Tab. The Power BI Table is added to the report.
Build Reports
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.
Note: Once you published the chart using the desktop version, the same will
be pushed to the Office 365 Power BI web version, where you need to
perform some actions to set the Refresh time.
➢ Refresh Frequency
➢ Time Zone
➢ Refresh between
4. Click Apply.
Note: At this point in time, you are almost done with the chart preparation in
which the data will be refreshed automatically according to the settings made
above—the only thing you need to do to make use of this chart on the
application page.
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.”
2. Share Report using Content Pack
a. In the web Power Bi page, click on the gear icon at
the top panel.
b. From the various option listed, select “Create
Content Pack.”
c. Provide the list of users’ email addresses for whom
you want to share the data analysis and select the
respective Report.
d. Click OK.
3. Share the Report using the URL or embedded URL:
a. In the web version Power BI page, you can find
“Report” in the left panel. Click on the report you
want to publish.
b. In the top panel, click on the “File” option.
c. Then click on “Publish to Web.”
d. A pop up will appear, which will provide you the
two options.
e. The link you can send in an email → the direct
URL which you can share with users.
f. Html, you can paste into your blog or website →
the code which you can add in “Embed content” of
your HTMLK page to display the data analysis.
g. Size → You can select the required size. Once you
select the size, the above “Html” code will change
accordingly.
In the same way, you will create other reports as per business needs.
Schedule Refresh
This section explains how to refresh the data in reports. You can schedule
refresh in a timely manner. Reports can be refreshed eight times per day.
Follow the steps to schedule refresh.
1. Open the Power BI app and gear icon and click on “Settings.”
2. Click on Datasets and click on the file which you need to
schedule refresh.
3. Go to “Scheduled refresh” and change it to “On” and add the
time, click on “Apply.” You can add another scheduled time.
To Host the power BI Reports in SharePoint, you need to publish the report.
To publish the report, open the report in Power BI and select publish to Web
option. This will open up with a dialog box showing Embed code and iframe
details. Make a note of these details.
Go to the SharePoint site to which the Power BI Report needs to
be hosted.
Click on the settings icon in the site and click on Add a page
option to create a web page.
Give proper Name and open the page in Editable mode.
Click on the insert web part option from the Ribbon.
Go to the Media and content category and in the parts select
Script Editor option.
Script Editor is added to the page.
Click on the Edit Snippet link in Top Right of the page.
Now copy the HTML iframe code and paste it to the snippet
editor.
A representation view of the image will be shown on the page.
Finally, click on insert, save, and publish the page in SharePoint.
You can use this tool to analyze and create quick reports and remove the
performance bottlenecks to improve the performance of the whole
application.
These reports are not only rich and interactive and but also users can make
changes without having to rely on another person. Users can pin reports to
workspaces themselves.
Power Query
for Report Generation
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.
Setting up Power Query
Power query can be downloaded from the following link Power Query
Download. The link also has other requirements that specify the software
requirements for installation.
1. After installation, navigate to the FILE menu. Click on
OPTIONS to enable the use of add-in.
2. Now select the Add-Ins tab, which is located on the left side of
the screen. Go to Manage Combo Box and then click COM Add-
Ins. Finally, select the GO button.
3. When you have the dialog box on your screen, check the
checkbox for “Power Query for Excel.” Once done, select the
OK button to continue.
4. After doing the above steps, there will be a new Power Query tab
present in MS Excel, as shown in the below image.
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.
Now you will try to implement the colorization of the regions based on their
availability. I.e., if the seat is available, it should display in green; it is not
available or booked, show it in red and if it is the driver seat, show it in
yellow.
For this, I am adding a new column as below.
Color = IF(Car[Status] = "Available", 1, IF(Car[Status] = "Booked", 2, 3))
Place the columns values as shown, and give the values for State 1 From = 1,
To = 1 and color = Green, for State 2 From = 2, To = 2 and color = Red and
for State 3 From = 3, To = 3 and color = Yellow
Similarly you can achieve any desired customized visualization as per the
requirement using Power BI Desktop.
Filters and Slicers
in PowerBI Report
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
Page filter applies to all the visuals on the specific report page. In a PowerBI
report, you can create multiple pages. As the name suggests, this page filter
gets applied only at the page level. Let’s consider you have created a
PowerBI report of multiple visuals from a single dataset on the first page.
If you want to apply the filter to another visual from the same page
(populated from the different dataset), the relationship has to be created for
both the datasets to enable the page filter.
Now when you apply the page filter, all the visuals get filtered based on the
filter. You can also have multiple columns added to a page filter.
Example: In the right pane (VISUALIZATIONS), under the FILTERS, you
will be able to see the PAGE LEVEL FILTER. Drag the necessary column
from the dataset and place it in the filter.
Now once you select a specific data from the Page-level filter (e.g.,
Australia), the whole page with all the visualizations gets filtered.
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
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.
If you click the image, it will show you the visuals which are marked in the
bookmark in which the image is linked.
Cognos Self Service BI
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.