Power Bi Moving Beyond The Basics of Power Bi and Learning About Dax Language
Power Bi Moving Beyond The Basics of Power Bi and Learning About Dax Language
Power Bi Moving Beyond The Basics of Power Bi and Learning About Dax Language
You can edit and transform data through changes in format, removing
rows, transposing data and the addition of columns
If you use a snowflake or star schema, you can use different
relationships between the data sets to obtain a granular understanding
of data
When you discover additional data, you can easily add this data to the
table. You do not have to recombine the data since you can integrate
numerous data sets on Power BI with ease. Since you can integrate
these data sets with ease, you have the flexibility to work with large
data sets.
When you use Power BI, you can ensure that the software will remember the
steps that you follow to prepare the data. You can simply repeat these steps if
there are changes made to the data. This helps to reduce and eliminate the
repetition of data preparation.
Spot Data Trends Quickly and Easily
You can spot different trends in the data set that you import into Power BI. You
will only need to look at the data set for a few minutes before you use the DAX
functions and other features in Power BI. You can look at the data set through
different attributes and dimensions. You can also include date-time dimensions .
If there is no schema structure, which means that the data does not have a date,
you can create this easily. This will allow you to use different time intelligence
functions. You no longer have to work with different macros across large files.
You only need to identify the right functions to use.
How to Create a Time Trend Analysis Using Power BI
1. You will first need to create a date dimension table. To do this, you
should use the function “New Table” in the Modeling tab in the
Power BI desktop. You can set the table as Date = calendarauto().
When you have the table with the dates from the data set, you can
create the date table. You can do this only if you use the DirectQuery
option.
2. Now, you need to establish a relationship between the variables in the
data and the data table. You will need to do this using a query, and
you can develop one using the Query Editor. All you need to do is
drag the fields from the tables and establish the relationship between
the data variables. Remember, the date dimension will connect
different data sets.
3. You can also go back to the report tab to help you create a visual that
will allow you to place the date on the X-Axis and the measure, like
sales or revenue on the Y-Axis, which depicts the value.
4. You can use additional measures using time intelligence functions like
Power BI. These have been detailed later in the book. When you click
on the table, you can select a new measure and enter it in the
following format: YTD_Measure = TOTALYTD
(sum(Table_Name[Value]),Dim_Date[Date])
Intuitive UX Features
Power BI also offers UX skills and options that will make the visualizations neat
and visually appealing. If you have used the Microsoft Office suite, you will
easily be able to use this feature since you only need to use the drag and drop
functionality.
When you use Power BI themes, it will be easier for you to create a consistent
color scheme. If you work for an organization, you can create a branding theme
based on the rules of the branding department. This format will be stored in a
.json file. Once you develop these formats, you can easily import the theme into
your dashboard. From here on, you can create the necessary charts and graphs.
Themes are simply .json files. These files contain numerous colors that are saved
in the HEX format, and you can create these formats and modify them using a
notepad file. This file can also be imported using Theme tabs in the Home
Ribbon in the Power BI service. You can use the following information to learn
more about how you can format the data: https://docs.microsoft.com/en-
us/power-bi/desktop-report-themes .
The Format Painter option in Microsoft Power BI will allow you to copy the
formatting across different visualizations. This will make it easier for you to
format the changes to individual visuals. You can also turn markers on inline
charts, place the data labels on the right axis in the chart, give people access to
create some custom format changes, and more. This will make the chart visually
appealing.
Incredible Cloud-Based Features
Now that you have created the dashboard, you need to publish it onto the cloud
service. You can also publish the reports that you create onto the service. You
can do this after you finish your analysis. When you use Microsoft Excel, you
will need to prepare the file, move it to SharePoint, and share the link to the file
on the cloud via email. This process has been changed with the introduction of
Power BI.
The data set is now on the Power BI service, which is an online cloud service. It
is here that the data can be refreshed easily. You can automate the refreshing of
the data set with ease. All you need to do is publish the data set onto the cloud
using the publish button.
Power BI not only allows for an easy publication and distribution of data but
also gives you different tools and methods that you can use to publish the data
and reports you have created to the cloud.
Quick Insights
Power BI offers you an easy way to gather some insights about the data that you
are looking at. You can use the quick insights option to do this. You can also
obtain a thorough analysis of the data set you have without opening the data set
in the application. You can also create a dashboard by clicking on the data set on
the Power BI Service. A dialog window will open up where you can see the
option called quick insights. Power BI will automatically create the model and
also establish a relationship between the variables in the data set.
Natural Language Query
This is an incredible feature that will allow you to type a question and answer.
You can either use a user-specified or a default form. This feature is useful for
any business user who is unfamiliar with how they can use Power BI. You can
also use this to identify the right tools you can use to represent data. This feature
will also save you from creating numerous visualizations on the dashboard to
answer a variety of questions. If you want to access this feature, you will need to
type the question in the box and then use the right tools to visualize the data.
Personalized Dashboards
When you use Power BI, you can create a dashboard that will allow you to
develop different visualizations from numerous reports. You can also use a
whole report if you want to. When you use these reports, you can customize the
layout of the page and the visuals as per your needs. You can lay the dashboard
in a way that will allow you to understand the data better. You can also connect
the dashboard to a different data source. You can share these dashboards with
different users in the organization, allowing them to view these visualizations. If
you want to improve a dashboard, check the tips mentioned in the last chapter in
the book.
Alerts
When you have created a dashboard, you can set up an email alter in the KPI on
the online service. When you right-click on the dashboard, a dialog window will
come up on the screen where you can choose to manage alerts. This will allow
you to set up an alert for when there are any changes in the data. This is a useful
tool for an employee since it will allow them to track a specific change in the
data. For example, if you check on inventory data, you can set up an alert that
will tell you when the inventory level increases or decreases.
Row Level Security Features
It is easy for users to add row-level security features in Power BI, and you can
do this easily even if you do not have coding experience. This was a complex
feature in Microsoft Excel. For example, an employee who uses RLS can look at
data that is specific to the local geography. You can always add these filters to
the report. This also makes it easier to protect the data used in the report from
being mailed to another user. When you want to set up the RLS, you should filter
for various roles that you can set up within Power BI. You can add the remaining
group or individual filters to the report using the Power BI online service.
You will need to select the option “Manage Roles” in the Modeling tab. You can
find this option in the security tab. You can choose the groups and create a role
for each of these groups using a DAX filter function (covered later in the book).
For instance, if you want to look at the data only for a specific country, you
should set the filter on the country to the country you are looking at.
Power BI makes it easier for organizations to function in a data-driven world. A
business can no longer focus only on IT to collect, collate, clean, transform, and
analyze data. they will need to have some powerful self-service abilities.
Organizations need to use Power BI so they can integrate different data sets,
expand into using newer data sources, visualize data easily, and deploy
numerous RLS filters. It is also easy to govern how the data is shared or used
since the user can determine how they want other people to view the data when
they share it on the cloud. This can be done through different features, including
the Natural Language Query. It is important that analytics companies and teams
always work with the data in the right way and also intelligently collect the data.
This is the only way they can evolve with the changes in consumer habits and
business needs.
Since the introduction of numerous data visualization tools, companies are doing
their best to incorporate various visualization methods and tools into their
analysis. You can also incorporate this tool for your organization.
Chapter Three: Power BI Data Sources
As mentioned earlier, Power BI does support numerous data sources. You can
simply use the Get Data option on Power BI, and this will give you a list of
sources and data connections that are available to you. You can connect to
different SQL databases, flat files, cloud services Like Azure, or even social
media platforms like Google Analytics, Salesforce objects, and Facebook. These
data sources also include an ODBC connection that will allow you to connect to
other data sources. These sources are not listed in this chapter.
Some of these data sources are:
Online Services
You can connect to different online services like Google Analytics, Facebook,
Exchange, and Salesforce to obtain data. The screenshot below shows you the
different options available under this category.
Other
The screenshot below will show you the different options under this category.
Chapter Four: Comparison of Power BI and Other
Tools
This chapter will compare Power BI with other tools like SPSS and Tableau.
Power BI Versus Tableau
Most businesses in the business intelligence market use Tableau as a leading data
visualization tool. Power BI is an emerging tool and is giving Tableau strong
competition. Power BI allows you to connect with numerous data sources and
allows you to manipulate data within the application itself. It is for this reason
that this data visualization tool is gaining popularity. Having said that, medium
and large enterprises still continue to use Tableau as their data visualization tool.
As mentioned earlier, Power BI is integrated with the Office 365 suite comma
and is compatible with numerous sources like Microsoft Excel, SharePoint, etc.
Feature Tableau Power BI
Data As mentioned earlier, Tableau is Power BI, on the
Visualization one of the leading data other hand, provides
visualization tools in the market. access to simple
visualizations and
allows you to
manipulate data at the
back end.
Size of Dataset Tableau allows you to connect with Power BI limits the
large volumes of data whenever number of records
necessary. you can include in the
data set and also sets
a limit of 1GB on the
amount of data you
can import into the
system if you use the
free version.
Data Sources Tableau, like Power BI, allows you Since Power BI is
to connect to numerous data integrated with Office
sources to import data for your 365, it also provides
analysis. Having said that, in access to cloud
Tableau, you first need to select the services like
data set before you visualize the SharePoint and
variables to perform an analysis. Azure. Power BI also
provides connectivity
to various data
sources that one can
connect within
Tableau. The online
version of Power BI
also supports
visualization on
cloud-based
applications like
Azure and
SharePoint. You can
also create direct
visualizations on
search engines, but
Bing is the only
Search Engine that is
compatible with this
tool.
In the image above, we are looking at a common data model. In this model, you
can see that there is a relationship between two tables. These tables can be
combined together using the primary column name “ID.” In the same way, you
can assign a relationship between two objects in the data set. You can set this
relationship by dragging a line between the columns that are common to both
tables. You can view these relationships using a data model in Power BI. Before
you create a data model in Power BI, you will need to choose the data source
that you want to use to perform the analysis. You can do this using the new
report option. If you want to add any data source, you should use the “Get Data”
option, and then select the source from where you want to obtain the data. Now,
click on the “Connect” button.
Once you choose the data source and add it to your application, you will see it
on the right side of the screen. In the image below, you can see that we have used
two Excel files – “Customer” and “Product” – to import the data into Power BI.
On the left side of your screen, you will see the following tabs:
- Report
- Data
- Relationships
If you navigate to the Report tab, you will see the chart that you selected for the
analysis and the dashboard. This is what you will need to use for data
visualization. You can also select different chart types or other visualization tools
as per your analysis. In the example used in this chapter, we have chosen the
method “Table” from the “Visualizations” tab.
You would have created a relationship between the data sets when you imported
the data source. When you navigate to the Data Tab, you will see the different
data sources based on the defined relationships that you have set.
In the relationship tab, you will see that there is a relationship between the tables
from the data sources. If you add numerous sources to the visualization in Power
BI, you can define the relationship between the different tables using a simple
relationship by establishing a link between the columns. When you move to the
Relationship tab, you will see the relationship that exists between the columns in
the tables. You can use the option “Create Relationships” to create a relationship
between various columns in the tables.
You can also add various relationships and remove them if needed in the data
visualization tab in the application. If you want to remove any relationship, you
should right-click on the relationship and choose the “Delete” option. If you now
want to create a new relationship, you need to drag the fields and drop them on
the tabs that you want to link.
You can also hide a specific column in the report that you create using the
“Relationship” view. If you want to hide a column, all you need to do is right
click on that column and then choose the option “Hide in report view.”
Creating Calculated Columns
When you analyze data, you may need to combine two columns to understand
how the data changes or moves. You can create a calculated column in Power BI
by combining elements in the existing data set. You can also define one or more
new columns in the data set by applying a calculation on a column that is present
in the data set. You can also create calculated columns to establish the
relationship between different tables sourced from the data sources. You can also
use this relationship to establish a relationship between these tables. If you want
to create a new calculated column, move to the “Data View” tab on your Power
BI screen and then select “Modeling.”
On the Power BI screen, you should navigate to the Modeling tab. In this tab,
you will see a “New Column” option. This will also open the Formula Bar, and
you can enter any DAX formula you need to use for this calculation. We will
learn more about these DAX functions later in the book. DAX refers to Data
Analysis Expression language that is powerful to use. You can rename these
columns by changing the Column Text in the formula bar.
Let us use a DAX function to create a new column in this data set. The column is
the Product Code (Product_C). This table is created based on the last three
characters in the column Prod_Id. You can write the following formula:
Product_C = RIGHT( Sheet1[Prod_Id],3).
You can also choose from a long list of formulae provided in the application.
You can use these formulae to create a calculated column. For this, you need to
enter the first character in the formula so you can use it in the formula. Look at
the screenshot below to understand this better.
Creating Calculated Tables
Power BI allows you to create a new calculated table using the data modeling
tab. If you want to create new tables, you should navigate to the Data View tab
on the left side of the Power BI screen. You can then move to the Modeling
option that is present at the top of the Power BI screen.
You can use the DAX expression to create new tables. You should also enter the
name of the new table on the Power BI screen. You need to use the same format
of formulae that you will use in Microsoft Excel. All you need to do is enter the
name of the table on the left side of the “=” sign. You should then include the
required DAX formula to perform the required calculation. When you finish
writing this calculation, you can create a new table that will appear on your field
pane. In the example below, let us now define a new table, “Table_CustC,”
which will return the column that contains a unique value.
You will find a new table under the “Fields” section on the screen. This is shown
in the screenshot below. When you create the calculated table and column as per
the requirement, you will see the fields in the report tab in the Power BI
application. If you want to add these objects, you will need to select the right
checkbox. You will then see the relationship between these objects. Otherwise,
you can drag between the columns that you want to build a relationship between.
If you want to view these reports correctly, you should navigate to the Report tab
in the Power BI tab. You can then see the “Calculated Columns” and the
“Calculated Tables” options in the report view of the Power BI.
Managing Time-Based Data
Power BI also allows you to drill through data based on time. If you add the data
field that you need to look at to the analysis, you can enable this drill version in
your data visualization. This will take you to another level in the time-based
data. Let us now consider the column “Time-based Table” that we have added to
this visualization. From the screenshot below, you can see that we have added
the tables “Year” and “Revenue.”
You can also enable this drill feature in any visualization using the option at the
top of the Power BI screen. Once you enable this drill feature and click on the
lines or bars in this chart, you can drill it down to the next level or feature in the
time hierarchy. For example, you can drill down from years to quarters to
months. You can also use this to move to the next level in the option and perform
a deeper drill.
Chapter Six: Power BI Dashboard Options
In this chapter, we will look at the different dashboard options that you can use
in the Power BI Application.
Exploring Different Datasets
The Power BI tool will provide you with numerous options that you can use to
explore the data set. When you work on a dashboard on Power BI or a report,
you can use the Power BI Look to obtain some quick insights about the data set.
You should navigate to the data sets section in the User interface. Click on the
three dots and choose the option. Get insights for the same.
When you choose this option, the Power BI user interface will run all the
algorithms in your data set. Only when this is complete Power BI will send you a
notification that will show you that your data set is ready for analysis.
You can then choose the “View Insights” option to obtain the necessary tools.
This will give you a representation of the data in the form of charts or bars. You
can view this option at any point during your analysis of the data set. You will
also get the option to obtain a Quick Insight about your data set when you
publish the report in Power BI .
Creating Dashboards
Power BI allows you to create a dashboard where you can pin the visualizations
that you obtain from the Power BI report that you publish on the Power BI
desktop. You can create these visualizations using the Power BI service. You can
pin these visualizations to your dashboard as well. If you want to pin a visual to
your dashboard in Power BI, you should open the report in the Power BI service.
You can then select the pin icon that is present at the top of the visual.
When you choose the pin option, you will see a dialog box appear on your
screen. This dialog box will appear in the following manner. You will be asked if
you want to create a new dashboard or if you want to use an existing dashboard
to put the visual on your screen. You can choose the visual from the dropdown
list. If you do not have any existing dashboards, Power BI will grey out the
second option.
When you choose the pin button, Power BI will throw you a confirmation that
you have pinned your visualization to the dashboard. You can then click on the
option “My Workspace” to check the dashboard and view the visualization.
When the dashboard is created, you can use numerous options to configure or
redesign that dashboard.
Sharing Dashboards
When you publish a report in Power BI using the Power BI Service, you can
either share the dashboards or reports with other users either within or outside
the organization. This makes it easier for you to share the dashboard in Power
BI. You can then open the dashboard using the Power BI Service and also click
on the Share option that is present at the top of the screen.
Having said that, you only have the sharing feature if you use the Professional
version. If you want to see how this works, you can use the 60-days trial.
All you need to do is click on the Try Pro for free to begin this trial version.
Now, select the Start Trial and follow the steps to click on Finish. You will then
receive a confirmation that the trial period has started. Now, enter the email ID
of the person with whom you wish to share this dashboard. You can also decide
if you want to allow these users to send email notifications about the changes
made to this dashboard or share this dashboard with other users. You can also
provide the URL to these users and access the dashboard directly.
Tiles in Dashboards
When you choose the more option in the dashboard, you will see the option
“Focus Mode” and many other options in this dashboard. Apart from this option,
you will also see other options on your screen. The focus mode will allow you to
take a close look at the data present in your dashboard. When you have
numerous values in the dashboard, you can use this mode to obtain a better view
of the objects present in this dashboard. If there are numerous columns in this
database, Power BI may not show you those tables. You can view these tables
using this Focus Mode .
The focus mode is used to view all the data in the report and dashboard. You can
also pin this visual directly onto the dashboard and other dashboards using the
Focus Mode. You can do this by selecting the pin icon. If you want to move out
of the focus mode, you should select the option “Exit Focus Mode.”
The Tile Details option will help you edit the format of the tiles on the
dashboard. This option will let you change the title, subtitle, the last refresh date
and time, and some other details about the tiles. This will allow you to create a
custom link to your dashboard.
Data Gateway
As mentioned earlier, you can connect to various on-premises data sources to the
Power BI service. This can be done using the data gateway option. You can use
the Personal Gateway, which will not include any administration configuration.
This is another version of the data gateway. You can set this gateway up by
logging into the service offered by Power BI. You can also select the download
icon on the top corner of the screen. You can do this by clicking on the Data
Gateway.
When you use on-premises data for your analysis, you can always refresh the
data if there are any changes made to the data. You also do not need to move this
data from the Power BI service. You can source the data using the Data Gateway
option. You can query a large volume of data using Power BI service. These
gateways will make it easier for you to provide all the flexibility you need to
meet any individual or organizational needs .
If you want to set up the download gateways, you will need to run the setup until
it is fully downloaded, and the installation process is complete.
You can choose from the following options:
You can also use other types of combination charts like the line and clustered
column chart.
Using Tables
When you add date-assist your visualization and Power BI, you will see that a
table chart has automatically been added to the report canvas. As mentioned
earlier, the table visualization is the default visualization chart used by Power BI.
You can always drag those fields that you want to use for your analysis to the
table. Alternatively, you can also include these fields to the table simply by
clicking on the checkbox present against the field names. If you have any
numerical values in the table, you will see the sum of these values at the bottom
of the column.
You are also allowed to start the data in your table using the sort option that
doesn't appear in the interface. This option is present at the top of the column in
the form of an arrow key. If you want to perform the ascending or descending
sort, you will just need to click on the respective arrow mark. The values in the
column will automatically be sorted.
Remember that the order is columns in every table in Power BI is determined by
order of the value on the right side of that column. If you want to change the
order of the column, you can either add another column or delete the column on
the right side of that column.
You can summarize, apply different aggregate functions, undo, or perform other
actions on numerical values present in the data table. If you want to change the
aggregation type you are using, all you need to do is Navigate to the value
bucket and click on the arrow in that bucket. You will then see a list of functions
that you can use to change the aggregation of the values in the data table.
You can also use a matrix table type in Power BI to perform an analysis. This
table provides numerous features like column tables, setting colors, auto-sizing,
etc .
Modify Colors in Charts
Power BI allows you to modify various colors in charts. If you select any
visualization, there are numerous ways in which you can change the color of the
axis and other variables present in this chart. The following options are available
in the format tab for a chart:
Data Colors
Legend
General
Detail Label
Background
Border
Lock Aspect
Title
You can view all these options in the Format tab. The screenshot below shows
you where you can find all the options available to you.
If you expand the legend field in the above options, you will have an option
where you can choose to display the legend, Ford, your visualization. You can
select the following options:
Color
Position
Legend Name
Title
Font Family
Text Size
You also have the option to choose numerous data colors. In case you want to
change the color of a column representing a data field in your table or chart, you
can use this option first up. This will show you all the objects in your chart and
the corresponding formatting options.
You can also use the analytics feature in the tool. This is where you can draw
lines or the analysis as per the requirement. You can use the following line types
in this tab:
Min Line
Constant Line
Percentile Line
Median Line
Max Line
Average Line
Alternatively, you can also choose a dotted, solid, or dashed line. You can
change the transparency level of the line comma, the position of the line, and the
color. You can also switch off or dealing the data label for this line.
Adding Images, Shapes and Text Boxes
There are times when you will need to include images, static text, shapes, and
other components to the data visualization. To do this, you will need to use the
header footer option. You can include static signatures or messages to the
visualization depending on your requirement. You can also add a URL to the text
box. Power BI will then make those links active. If you want to add images, text
boxes, or shapes to the visualization, move to the home tab and choose the
option to add images.
You can also include different shapes to the visualization that you have
developed. If you want to look at the available shapes, you should navigate to
the shapes button and click on the arrow next to it.
When you select the text box, you will see that a text box has been created on the
report canvas. You can either enter some text in that box or use the rich text
editor to format the box and make any changes.
You can also add images to the data visualization in a similar manner. You can
add images like logos to the visualization. To do this, you need to click on the
image option an enter the path to pass the file that contains the image. You can
also add various shapes by selecting the shapes that are present in the drop-down
list. Power BI also allows you to resize these shapes and images using various
options.
Styling Reports
Power BI gives you the option to adjust the page layout for stop. You can also
format the layout by changing the page size and the orientation. To do this, you
should move to the page view menu in the Home tab where you will find the
following options:
Actual Size
Fit to Width
Fit to Page
In Power BI, the default page size is 16: 9. You can, however, change the size of
that page for the report. If you want to change the page size, you should move to
the visualization pane in the report canvas and click on the paintbrush option.
Remember, you need to change the page size before you add any visualization to
the report canvas. You can choose from the following options under page layout:
Page Size
Page Background
Page Information
Under the page information tab, you only have the options Q&A and name.
under page size, you can choose from the following options:
Width
Type
Height
Under the page background option, you can choose from the following options:
Transparency
Add Image
Color
Duplicating Reports
In some scenarios, you can choose to use the same layout and visualizations for
various other pages. Power BI allows you to create a copy of the page with the
report in it. When you use the option “Duplicate Page,” you will see that a new
page has been created with this same visuals and layout. If you want to create a
duplicate of any page, right-click on the page and choose the option “Duplicate
Page.” This will create a page with the name duplicate of Page 1.
If you want to delete the existing page or rename it, you can use the other
options that are present in the dialog box.
Chapter Eight: How to Share Power BI Dashboards
In this chapter, we will learn how you can share a power be I dashboard printing,
report sharing, publishing, etc.
Using Power BI Desktop to Share Reports
When you create a Power BI report, you can share that report with other users
only if you have created that report on a Power BI desktop. All Power BI
dashboards, data, and reports can be shared with business users and colleagues in
the organization. You can use the following methods to share reports with these
users:
Use content packs to combine reports, data sets and dashboards that
are created in the Power BI desktop tool
You can publish the report directly using the Power BI service
You can use the Power BI mobile application to access any shared
reports or dashboards
You can create a group and share the dashboard, report, data and
other information with this group will stop Having said that, you can
assign specific rights to those users
Let us now look at how you can publish a Power BI report using the desktop
tool. When the report is created in the Google Power BI desktop, you should
navigate to the publish button. This button is present in the home tab on the
desktop.
When you select the publish service option, the custom measures, reports, and
visuals are packaged and published to the service. These files will have the
extension “.pibx.” While the upload is still in process, you will receive a
notification from Power BI with the status of the upload.
Once Power BI completes this upload, you will receive a confirmation message
which will tell you about the success or failure of the upload. You can also
obtain some quick insights about the reports or the data. To view these quick
insights, open the shared report from the dialog box.
Printing Power BI Dashboards
You will also need to take some printouts of your dashboards or reports. Power
BI allows you to do this easily. If you want to take a printout of the report,
navigate to the Power BI Service and click on the option “…”
This will open a print dialog box that you can use. You can then choose the
printer on which you want to take a printer off that report. You can also choose
different print options like margins, header, scale, portrait, or landscape .
Export Options
Power BI will also allow you to export the report, dashboards, or the data set
directly from the Power BI Report. If you want to use the export option, you
should navigate to the Power BI service and choose the power bear report that
you wish to export.
When you choose the export option, Power BI will generate a CSV file. You can
also view or export the report directly using the print option.
Publishing Report to Web
Power BI also allows you to publish the report to a cloud service or on the web.
It also allows you to share this report via email. If you want to publish a report to
a cloud service or web, you should navigate to the workspace in the Power BI
service.
When you open the report you wish to publish, you should navigate to the
publish to web option in the File tab. Once you select this option, Power BI will
open a new dialog box, which will create an embedded code for this report. You
can embed this code in an email or on a website. When you click on this option,
a dialog box will open, which will say the following: “Get a link or embed code
that you can include on a public website. You may use publish to web
functionality to share content on a publicly available website. You may not use
this functionality to share content internally, which includes your email, your
internal network, or intranet site. Publish a live version that will remain
synchronized with the source report in Power BI. Any changes you make to the
report will immediately be reflected in the published public version. ”
When you choose the option to create embed code, Power BI will prompt you to
share the data with everybody on the Internet. When you select this option
comma, the following message will be displayed: “You are about to create an
embed code for this report. Once published, anyone on the Internet will be able
to access the report and the data it contains, and Microsoft may display the
report on a public website or a public gallery. ”
Before you publish this report, you must ensure that you have the right to share
this data publicly. You should never publish any proprietary or confidential
information. You also cannot share anybody's personal information on the web.
If you are in doubt, you should check the policies of your organization before
you publish that data set. You can also publish the report that you create in the
form of a web page. You can share this link with any user. Power BI will share
this link via email so that it can be used as an inframe.
Deleting an Embed Code
Let us assume that you want to delete the embedded code created for the rept.
For this, you should navigate to the gear icon present the Top of the screen. You
can then go to the option “Manage embed codes.”
If you want to remove the embedded code, click on the ellipsis mark, which is
present in front of the report name. You can then delete that option .
Choose the delete option, and Power BI will ask if you want to delete the
embedded code that is published on a web page. If you are sure, you can click on
delete.
Using Content Pack
You can also share reports, datasets, and dashboards in power behind the form of
a package. You can share these packages with your colleagues or other users. If
you want to create a content pack, navigate to the gear box in the workspace, as
shown in the screenshot below.
When you choose the create content pack in the dialog box, Power BI will
prompt you with a new dialog box. You can select the option to distribute this
path with the entire organization or specific groups alone. If you want to share
the report only with specific people, you will need to enter their email addresses
will stop you can also add a description and a title of the content package that
you are sharing .
If you look at the screenshot below, you will notice that you can choose the
components that you want to publish. You can choose from the following
options:
Reports
Dashboards
Datasets
The DAX function will also include conditional statements, functions, and value
references. Let us look at some key points about DAX that will enable you to
understand these concepts in an easier way.
Information
Date
Text
Counting
Logical
Aggregate
Power BI will also provide a very easy way to list the various functions you can
use in Power BI. When you start typing the formula in the formula bar in the
Power BI screen, you will see the list of the functions that start with that
alphabet. This is similar to Microsoft Excel.
Aggregate Functions
There are numerous aggregate functions that you can use in Power BI like:
SUM
SUMX
Max
Min
Average
Counting Functions
Some of the counting functions you can use in DAX are:
COUNT
COUNTA
COUNTROWS
COUNTBLANK
DISTINCTCOUNT
Logical Functions
The following are the numerous logical functions one can use in Power BI:
AND
OR
NOT
IF
IFERROR
TEXT Functions
Some of the text functions you can use in Power BI include the following:
REPLACE
SEARCH
UPPER
FIXED
CONCATENATE
DATE Functions
Some DATE functions used in Power BI are:
DATE
HOUR
WEEKDAY
NOW
EOMONTH
INFORMATION Functions
Some functions used are:
ISBLANK
ISNUMBER
ISTEXT
ISNONTEXT
ISERROR
DAX Calculation Types
You can use two types of calculations when you use DAX:
Calculated Measures
Calculated Columns
You can see the New Column option in the Modeling tab in the Power BI
Desktop interface. This option will be present at the top of the screen. When you
select this option, a formula bar will open. This is where you should enter the
DAX formula to perform the required calculation. The Data Analysis Expression
is a language used in Excel to perform calculations too. You can rename these
columns by changing the Column text in the formula bar in the Power BI
desktop.
In the example below, we will create a new column called Product Code
(Product_C). This column is derived from the last three characters in the Prod_Id
column. This is the formula used: Product_C = RIGHT( Sheet1[Prod_Id],3).
If you want to create a new measure, you should move to the Modeling tab and
choose the “New Measure Tab” option. This will allow you to include a new
object with the name “Measure” in the Fields tab.
DAX functions and formulae can be used to calculate the value of new measures
in the same way that we calculated a new column. Experts state that DAX
formulae are also called calculations since they calculate the input value to
obtain a resultant value. You can always create two types of measures in Power
BI using DAX: calculated measures and calculated columns.
Calculated Columns
A calculated column will create a new column in the table that is present in the
Report pane of the desktop. The difference between a calculated column and
regular column is that you need to have at least one function in this column. You
will use these values when you create a column with sorted or filtered
information. Follow the steps below to create a calculated column:
3 table
This is a DAX expression that will return the output in the form of a
table.
4 tableName
This is the name of the existing table that uses the DAX syntax.
Remember, this cannot be an expression.
5 columnName
The name of an existing column using standard DAX syntax, usually
fully qualified. It cannot be an expression.
6 Name
The name is a string constant that can be used to name any object.
7 Order
The order will determine how the data needs to be sorted.
8 Ties
Ties will determine how you can handle the tie values.
9 type
The type enumeration can be used to determine the type of data you
can use for PathItemReverse or PathItem .
Prefixing Parameter Names or Using the Prefix Only
A parameter can be qualified using a prefix:
Based on the labeling in the image above, an explanation is given below about
the elements in the formula:
A: This is the name of the measure that you are adding to the
visualization
B: If you remember from Microsoft Excel, you always begin a
function after the “=” sign. This operator in Power BI equates two
sides of the DAX formula and is the start of the DAX formula
C: This is the DAX function that you will use to add the values from
the two tables in the data set. Since we are taking the sum of the
values, we will use the SUM function
D: The parenthesis used in the function will enclose and define the
arguments that you will use in this expression. Remember every
function will have at least one argument
E: This lists the name of the table from where the column or field will
be taken from
F: This is the name of the field in the table from where the formula
will use the values. For example, in this formula, we will use the
function SUM to apply the values of the field or column
G: This is another operator that is used in DAX for multiplication.
The syntax elements are from A to F, and these constitute the basic
syntax of the DAX function
In simple words, the DAX formula will command the system to add the values
in the Total Sales 2018 column and the projection column. It will then store these
values in the new measure or column called Projected Sales 2019.
Parameters
We have covered the various parameters in the previous chapter. For each of the
function groups that we will cover in the later sections of the book, we will look
at the parameters in a table along with the description.
Return Value
The return value will determine the data type of the value that the function will
return after it runs through the formulae.
Remarks
In the remarks section of any function, you will need to add some extra
information about why you are using the DAX function. This will also help you
identify any errors and also debug the formula.
Chapter Twelve: Aggregate Functions
This chapter lists the different aggregate functions used in DAX.
ADDCOLUMNS
This function will allow you to add columns to any table expression or table.
Syntax
ADDCOLUMNS (<table>, <name>, <expression>, [<name>, <expression>] …)
Parameters
Sr.No. Parameter & Description
1 table
This parameter will indicate to Power BI that it should return a table
2 name
This parameter will indicate the column that we will be using. This
will be included in double quotes
3 Expression
This parameter will return a scalar expression that is evaluated for
every row in the table
Return Value
This function will return a table with all values – both the original and added
values.
Example
PRODUCT_SALES = ADDCOLUMNS (
Products,"East_Sales", SUMX (RELATEDTABLE(East_Sales),
IF([Product] = East_Sales[Product], East_Sales[Sales Amount],0)
)
)
AVERAGE
This function will return the arithmetic mean or average of the numbers in the
specified column.
Syntax
AVERAGE (<column>)
Parameters
Sr.No. Parameter & Description
1 Column
This parameter will return the numbers that you want to calculate an
average of .
Return Value
This function will return a decimal number that will represent the arithmetic
mean of the numbers present in the column.
Remarks
If there are any empty cells or logical values in the column, the values
will be ignored. These rows will not be counted
A cell with a null value will not be included, but the rows will be
counted for the divisor
If there are no rows that can be aggregated, the function will return a
blank value. Having said that, if the rows in the table do not meet
some criteria, the value returned will be zero
Example
= AVERAGE (Sales[Sales Amount])
Types
Some of the other versions of this function are:
AVERAGEA
This function returns the average of the values in a column, including non-
numeric and text values.
Remarks :
This function will take the column and will calculate the average or the
arithmetic mean of the numbers present in that column. The column will need to
adhere to the following rules:
Any value that will evaluate to “TRUE” will be assigned the number
1
Any value that will evaluate to “FALSE” will be assigned the number
0
Any empty text will be assigned the value zero
The non-numeric text will be counted as zero
Syntax :
= AVERAGEA (East_Sales[Sales Amount])
AVERAGEX
This function will calculate the average of all the expressions used in a table.
Remarks :
This function will enable you to evaluate different expressions across the row in
any table. It will then take the results and then calculate the arithmetic mean of
those values. Therefore, this function will take the table as the first argument and
also the expression as the second argument in the function. This function will
follow the same rules as the AVERAGE function, which means that you cannot
include null cells or non-numeric cells.
Syntax :
= AVERAGEX (East_Sales,East_Sales[Unit Price]*East_Sales[No. of Units] )
COUNT
This function will count the number of cells that are present in a column which
contains numbers.
Syntax
COUNT (<column>)
Parameters
Sr.No. Parameter & Description
1 column
This parameter will indicate the column where the numbers should
be counted.
Return Value
This function will return a whole number.
Remarks
You can use this function to count the number of records in a column, but only
the numbers present in this column are taken into consideration. The following
values will be counted in the column if you use this function:
Dates
Number
If these rows contain text, you cannot expect Power BI to translate that text into
a number. This means that the row will not be counted. When the function does
not find the rows to count, it will return a blank value. If there are rows and none
of those rows meet the criteria, the function will return zero.
Example
= COUNT (ProductInventory[UnitsBalance])
Types
COUNTA
This function is used to count the number of cells present in a column which are
not empty. This means that this function can be used to count those rows that
include nonblank values, including dates, logical values, and text.
Remarks :
If the function does not find the rows in the table to count, it will return a blank
value. If there are rows, but none of those rows meet any criteria, the value will
be zero.
Example :
= COUNTA (ProductInventory[UsageDate])
COUNTAX
This function will count the nonblank values when an expression over a table is
being evaluated. This function works like the COUNTA function, which means
that it can iterate through different rows in the table where there are no blanks.
Syntax :
COUNTAX (<table>, <expression> )
Parameters :
Sr.No. Parameter & Description
1 table
This parameter returns the table, which contains the row in which the
expression will be evaluated.
2 expression
This parameter will list the expression that should be evaluated in
every row in this table.
Remarks :
This function will count the number of cells that contain any form of
information. This information includes expressions as well. For instance, if the
column you are using contains an expression which you will use to evaluate a
string, this function will treat the record as a non-blank record. The COUNTAX
function will not count any empty cell, but since this cell contains a formula, the
cell will be included in the list. If there is no row for the function to aggregate,
the function will return a blank value. Having said that, if the rows do not meet
the criteria, the value of the function will be zero.
Example :
Medal Count Summer Sports:= COUNTAX (
FILTER (Results, Results[Season] = "Summer"), Results[Medal]
)
COUNTBLANK
This function will return the number of blank cells that are present in a column
in a table.
Example :
= COUNTBLANK(Results[Medal])
Remarks :
When you use this function, you can use columns that contain any kind of data.
This function will count the number of blank cells in the table. Even those cells
that have the value zero will not be counted since this number is a numeric data
type and not a blank.
Example :
= COUNTBLANK (SalesTarget[SalesTarget])
COUNTROWS
This function is used to count the number of rows in a table or the table specified
by some expression.
Syntax :
COUNTROWS (<table> )
Parameters :
Sr.No. Parameter & Description
1 table
This parameter will indicate the name of the table that will be used
by the function to count the number of rows. This parameter can also
indicate the expression that will return the table.
Remarks :
This function is not only used to count the number of rows present in the base
table but also used to count the number of rows present in a table after a context
or filter is applied to that table.
Example :
= COUNTROWS (CALENDAR (DATE (2016,8,1), DATE (2016,10,31)))
returns 92.
= COUNTROWS (Results) returns 34094.
= COUNTROWS (Events) returns 995.
COUNTX
This function will count the number of rows that are present in a table that
contain an expression which will evaluate a number or number.
Syntax :
COUNTX (<table>, <expression>)
Parameters :
Sr.No. Parameter & Description
1 table
This parameter will return the value of the table, which contains the
rows that you want to count.
2 expression
This parameter will return the number that you want to count.
Remarks :
This function will only count numeric values in the cell, including dates. The
parameters which use logical values or text will not be translated into numbers,
and therefore, are not counted. If this function does not find any rows that it can
count, it will return a blank value. If none of the rows in the table will meet the
specified criteria, the function will return the value zero.
Example :
= COUNTX (RELATEDTABLE (East_Sales), IF ([Product] =
East_Sales[Product],1,0) )
CROSSJOIN
This function will return the value as a table, which contains the Cartesian
product of the values that are present in the rows from the tables included in the
parameter list of the function. The columns in this new table will include the
columns from all the parameter tables.
Syntax
CROSSJOIN (<table1>, <table2>, [<table3>] …)
Parameters
Sr.No. Parameter & Description
1 table1
This parameter will return the name of the first table to use in the
DAX expression.
2 table2
This parameter will return the name of the second table to use in the
DAX expression.
3 table3
This parameter will return the name of the third table to use in the
DAX expression. This is an optional parameter .
Return Value
This function will return the value as a Cartesian product of the values of the
rows present in the tables used as a parameter in the function. The columns in
the new table will return the columns in the parameter tables.
Remarks
The names of the columns from the tables used as parameters should
be different in all the tables. Otherwise, you will receive an error
The number of rows in the result table will be a product of the
number of rows present in the tables entered as the parameter
The total number of columns present in the result table will be the
sum of the number of columns present in the tables entered as the
parameters
For instance, if the first table has r1 rows and c1 columns, the second table has
r2 rows and c2 columns, and the third table has r3 rows and c3 columns, the
resulting table will have: r1*r2*r3 rows and c1+c2+c3 columns.
Example
= CROSSJOIN (Salesperson, Products)
DISTINCTCOUNT
This function is used to count the number of distinct values present in this
column .
Syntax
DISTINCTCOUNT (<column>)
Parameters
Sr.No. Parameter & Description
1 column
This parameter will return the list of values that must be counted.
Return Value
This function will return a whole number.
Remarks
If you want to use this function, you can use a column that contains any type of
data. If the function does not find any rows to count, it will return a blank value.
Example
= DISTINCTCOUNT (Sales[Account])
GENERATE
This function is used to return a table that contains the Cartesian product of the
rows that are present in the table entered as the parameter and the table that is
returned as a result of evaluating the second table in the context of the first table.
Syntax
GENERATE (<table1>, <table2>)
Parameters
Sr.No. Parameter & Description
1 table1
This parameter will return the value of the first table that should be
used in the DAX expression.
2 table2
This parameter will return the second table, which needs to be
evaluated under the pretext of the first table.
Return Value
This will return a value as a parameter that can be passed into a DAX function.
Remarks
If the resulting table when the second table is evaluated based on the
first table comes up empty, the final table will not contain any rows
from the first table. This is different from the GENERATEALL
function. In this function, all the rows from the first table will be
included even if the second table does not have any entries
The column names in both tables should be different
Example
= GENERATE (
SUMMARIZE(Salesperson,Salesperson[Salesperson]),
SUMMARIZE(SalesTarget,SalesTarget[SalesTarget],
"MaxTarget",MAX(Sales Target[SalesTarget]))
)
Types
GENERATEALL
This function will return a table that is the Cartesian product between the rows of
the first table and the table, which results from evaluating the second table in the
context of the first table.
Syntax :
GENERATEALL (<table1>, <table2>)
Example :
= GENERATEALL (
SUMMARIZE(Salesperson,Salesperson[Salesperson]),
SUMMARIZE(SalesTarget,SalesTarget[SalesTarget],
"MaxTarget",MAX(Sales Target[SalesTarget]))
)
MAX
This function will return the largest value that is present in the column.
Syntax
MAX (<column>)
Parameters
Sr.No. Parameter & Description
1 column
This parameter will return the column within which you want to
find the largest numeric value.
Return Value
The function will return a decimal number.
Remarks
This function will consider the following types of values when looking for the
maximum value:
Dates
Numbers
The function will ignore logical values, text, and empty cells.
Example
= MAX (Sales[Sales Amount] )
Types
MAXA
This function, like the MAX function, will return the largest value in the column.
Remarks :
This function will take a column as the argument and will look for the maximum
value from the following data types:
Dates
Numbers
Logical values like TRUE and FALSE. The row with TRUE will be
valued as one, and that with FALSE is valued at zero
An empty cell is always ignored. If the column does not contain any values
which adhere to the criteria, this function will return zero.
Example :
= MAXA (ProductInventory[UsageDate])
MAXX
This function will evaluate the expression in every row in the table and then
return the cell value with the largest number.
Remarks :
This function will only evaluate the following values:
Dates
Numbers. If the expression does not return a number, the value
returned by the function is zero
Text values, logical values, and empty cells are ignored.
Example :
= MAXX (East_Sales,East_Sales[No. of Units]*East_Sales[Unit Price])
MIN
This function will return the smallest numeric value that is present in the column
entered as the parameter.
Syntax
MIN (<column>)
Parameters
Sr.No. Parameter & Description
1 column
This parameter will return the column in which you are looking for
the minimum values.
Return Value
The function returns a decimal number.
Remarks
The function only considers the following types of values:
Dates
Numbers
Text, empty cells, and logical values are ignored.
Example
= MIN (Sales[Sales Amount])
Types
MINA
This function will return the smallest value present in the column, including the
numbers represented as text and logical values.
Syntax :
MINA (<column>)
Remarks :
The function will consider those cells with the following values:
Dates
Numbers
Logical values like TRUE and FALSE. The row with TRUE will be
valued as one, and that with FALSE is valued at zero
Text that can be converted into a numeric value
As with the previous function, this function also ignores empty cells. If the cells
in the columns do not contain any values, the function will return zero .
Example :
= MINA (ProductInventory[InventoryDate])
MINX
This function will return the smallest numeric value that is present in the
column. It will either look for numeric values or look for those expressions that
return numeric values.
Remarks :
This function will evaluate the result of the expressions based on the following
rules:
Return Value
This function will return a decimal number.
Remarks
This function will only look at the numbers present in the column entered as the
parameter. It will ignore the text, blanks, and logical values.
Example
= PRODUCT (ProductInventory[InventoryDuration])
Types
PRODUCTX
This function will return the product of those numbers that result from when an
expression is evaluated for every row in the table entered as the parameter .
Syntax :
PRODUCTX (<table>, <expression>)
Parameters :
Sr.No. Parameter & Description
1 table
This parameter will return the table, which contains the row for
which the expression must be evaluated.
2 Expression
This parameter will return the expression that will need to be
evaluated for every row in the table.
Remarks :
This function will only consider those numbers in the column. Text, blanks, and
logical values will be ignored.
Example :
= [PresentValue] * PRODUCTX (AnnuityPeriods, 1 + [FixedInterestRate])
ROW
This function will return the table with only one row. This row will contain the
values that will result from the expression that is given in the columns in this
table.
Syntax
ROW (<name>, <expression>, [<name>, <expression>] …)
Parameters
Sr.No. Parameter & Description
1 name
This parameter is the name of the column, which is enclosed in
double-quotes.
2 expression
This parameter or expression will return a scalar value that will help
to populate the column mentioned above
Return Value
This function will return a table with one row.
Remarks
You need to include a pair of names and expressions when you use this function.
Example
= ROW (Total Number of Products, COUNTA (Products,
Products[Product_key]),
Total Sales Value, SUM (Sales, Sales[ExtendedAmount]))
SELECTCOLUMNS
This function will add all the calculated columns in a table expression or a given
table, and it was introduced in the year 2016.
Syntax
SELECTCOLUMNS (<table>, <name>, <scalar_expression>, [<name>,
<scalar_expression>] …)
Parameters
Sr.No. Parameter & Description
1 table
This parameter is either a DAX expression that can return a table or a
table.
2 name
This parameter is the name that is given to the column, and this is
enclosed in double-quotes.
3 scalar_expression
The DAX expression will return a scalar value, which can be an
integer, string, or column reference.
Return Value
This function will return a table with the same number of rows that are present in
the table mentioned in the parameters of the function. The table that is returned
will have one column that is named after each pair of scalar_expression and
name parameters. Every scalar_expression will always be evaluated in the
context of some row in the table specified as the parameter .
Remarks
This function is similar to the ADDCOLUMNS function and behaves in the
same way except that it will not start only with the table specified. This function
will always begin with an empty table, and columns will be added to it based on
the results provided by the function.
Example
= SELECTCOLUMNS (
Products,"Product-NoOfUnits",Products[Product]&" - "&Products[Units
Sold])
SUM
This function will return the sum of the numbers present in a column.
Syntax
SUM (<column>)
Parameters
Sr.No. Parameter & Description
1 column
This parameter will contain the name of the column that contains the
numbers that are used to calculate the sum.
Return Value
This function returns a decimal value .
Remarks
This function will return a null value if the rows contain non-numeric values.
Example
= SUM ([Sales Amount])
SUMMARIZE
This function will return the summary table that you request over a set of
columns or groups.
Syntax
SUMMARIZE (<table>, <groupBy_columnName>, [<groupBy_columnName>]
…,
[<name>, <expression>] …)
Parameters
Sr.No. Parameter & Description
1 table
This parameter returns a DAX expression that will return the table of
data.
2 groupBy_columnName
This parameter will provide the list of the existing column that can be
used to create a group or summary based on the various values
present in the column. You cannot use an expression in this
parameter.
3 name
This function will return the name of the total of the column. The
name of the column is enclosed in double-quotes.
4 expression
This parameter will return the scalar value, and the expression will
need to be evaluated for every row or context .
Return Value
This function will return a table with the names of the columns written in the
parameter groupBy_columnName. The summary of these columns will be
named based on the name parameters.
Remarks
Every column that you define will need to have a corresponding
expression. If there is no expression, an error will occur. The first
parameter in this function will define the name of the column that
will be used in the result. The second parameter called the expression
will define the calculation that will be performed to obtain this value
for every row in the selected column
You should have the groupBy_columnName either in a table related
to a table or in a table alone
Every name should always be enclosed in double quotes
The function will group a selected set of rows into one set of values.
These values will be grouped into groupBy_columnName. The
function will return a value for every group in that list
Example
= SUMMARIZE (
SalesTarget,SalesTarget[SalesTarget],"MaxTarget",MAX
(SalesTarget[SalesTarget]))
SUMMARIZE With Options
Now that you know what the summarize function does let us look at how you
can use different options within that function. You can use the following options
within the summarize function:
ISSUBTOTAL function
ROLLUP function
ROLLUPGROUP function
If you use these functions in the SUMMARIZE function, you will obtain
different results:
Return Value
This function returns a decimal number as the value.
Remarks
This function will only return the number present in the column that where the
expression can be evaluated. The cells with text values, logical values, or blanks,
will be ignored.
Example
USA Gold Medal Count:= SUMX(
Results,IF(AND([Country] = "USA",[Medal] = "Gold") = TRUE(),1,0)
)
TOPN
This function will return the maximum number of rows that have been specified
in the table .
Syntax
TOPN (<n_value>, <table>, <orderBy_expression>, [<order>],
[<orderBy_expression>, [<order>]] …)
Parameters
Sr.No. Parameter & Description
1 n_value
This parameter will determine the number of rows that the function
should return. This parameter will be a DAX expression that will
return a scalar value, and the expression is evaluated numerous times
for each context or row.
2 table
This parameter will return a DAX expression that will return the
table with the data where it will need to extract the top n_value
number of rows present in the table.
3 orderBy_expression
This parameter is a DAX expression which is used to sort the table.
This parameter will be applied to every row in the table.
4 order
This is an optional parameter to use. You can specify the value
depending on which the rows will be sorted:
FALSE or zero: This will sort the data in a descending orde r
TRUE or one: This will sort the data in an ascending order
Return Value
This function will return either of the following values:
Remarks
This function will evaluate the following based on a combination of items from
various columns:
The arguments passed to the ALL function should either be a reference to a base
column or a base table. You can never use the table expression or column
expression if you use this function.
Return Value
This table will return a table, column, or columns without any filters.
Remarks
You cannot use the ALL function by itself. You will need to use it as an
intermediate function, and you can change the set of the results obtained using a
calculation.
Example
= COUNTA (Results[Medal])/CALCULATE (COUNTA (Results[Medal], ALL (
Results))
When you use this DAX formulae, the rows in the resulting table will be
considered in the CALCULATED function with the ALL function containing a
filter. When you do this, you will need to include the total number of values in
the denominator.
ALLEXCEPT
This function will always remove the context filters used in the table. It will,
however, not remove those columns that specifically have filters applied to them.
Syntax
ALLEXCEPT (<table>, <column>, [<column>] …)
Parameters
Sr.No. Parameter & Description
1 table
This parameter is the name of a table which will contain no context
filters. The table can, however, include filters for those columns
where they have been applied specifically.
2 column
This parameter will contain one or more columns which will specify
the context filters, and these must be preserved.
If you use the ALLEXCEPT function, you will need to first refer to the base
table. The other arguments in the function can only be references made to the
base table. You can never use a column expression or table expression with the
ALLEXCEPT function .
Return Value
This function will return a table without any filters used in the table, except for
those columns with filters.
Remarks
The ALLEXCEPT function can never be used by itself. It will serve as an
intermediate function that can be used to change the results over a specific
calculation performed. You can also use this function if you want to remove the
filters but never remove the columns in the table.
Example
= CALCULATE (COUNTA (Results[Medal]), ALLEXCEPT (Hosts,
Hosts[City]))
The values in the Medal column in the above formula is present in the Results
table. These values will be counted without any filters except for those filters
that are present in the Hosts table in the column City.
Types
ALLBLANKROW
This function will return the rows in the table except for the blank rows. It will
also return the distinct values of the columns present in the table but the blank
rows. The function will disregard those filters that are context in nature .
Syntax :
ALLNOBLANKROW (<table>|<column>)
Return Value :
This function will return the following values:
Remarks :
Return Value
This function will return the result of the expression entered as the parameter.
Remarks
The function will use the expression as the first parameter. This is the same as
the calculated field. If you use a Boolean expression as the argument, the
following rules will apply:
You cannot use a function in the expression that will either scan or
return a table, including an aggregate function
Expressions cannot use nested CALCULATE function
You cannot reference a calculated field in the expression
You can, however, use a Boolean expression to use a function that will look for a
single value. It will return a scalar value. If you filter the data, the CALCULATE
function will change how the data is filtered. It will also evaluate the expression
in a new context that you define or specify. For every column that you use in the
filter argument, you can use existing filters on the column, which is removed.
You can also filter the arguments instead.
Example
= COUNTA (Results[Medal])/CALCULATE (COUNTA (Results[Medal], ALL
(Results) )
CALCULATETABLE
This function will evaluate the table expression based on the given filters.
Syntax
CALCULATETABLE (<expression>, [<filter1>], [<filter2>] …)
Parameters
Sr.No. Term & Definition
1 expression
This parameter shows the expression that should be used to evaluate
the table.
2 filter1, filter2 …
This parameter is a Boolean expression that will define a filter to be
used in a table expression.
Return Value
This function will return a table with values.
Remarks
The expression which is used as the first parameter should be in the form of a
function so it can return a table as the output. If you use a Boolean expression as
the argument, the following conditions will hold true:
You cannot use a function in the expression that will either scan or
return a table, including an aggregate function
Expressions cannot use nested CALCULATE function
You cannot reference a calculated field in the expression
You can, however, use a Boolean expression to use a function that will look for a
single value. It will return a scalar value. If you filter the data, the CALCULATE
function will change how the data is filtered. It will also evaluate the expression
in a new context that you define or specify. For every column that you use in the
filter argument, you can use existing filters on the column, which is removed.
You can also filter the arguments instead. This function is also used in place of
the RELATEDTABLE function.
Example
= SUMX (
CALCULATETABLE (East_Sales,
FILTER (East_Sales, East_Sales[Product]=[Product])),
East_Sales[Sales Amount]
)
CROSSFILTER
This function will specify the cross-filtering direction that Power BI will need to
take to calculate a value based on a relationship that exists between two or more
columns. This function was introduced in 2016.
Syntax
CROSSFILTER (<columnName1>, <columnName2>, <direction> )
Parameters
Sr.No. Parameter & Description
1 columnName1
This parameter will include the name of the column that will
represent the type of relationship that needs to be used - the data
table side or many sides. If the arguments are not given in the right
order, the function will swap the order before it uses the arguments.
The arguments used cannot be expressions.
2 columnName2
This parameter is also a name of the column, which represents the
type of relationship to be used – one side or lookup table side. If the
arguments are not given in the right order, the function will swap the
order before it uses the arguments. The arguments used cannot be
expressions.
3 Direction
This parameter will define the direction in which the cross-filter
should be applied:
One − Filters on one or lookup table side of the relationship filter
with many sides.
Both − Filters on either side filter the other.
None − No cross-filtering occurs along with this relationship .
Return Value
This function will not return any value, but will only set the direction in which
cross-filtering should take place for any indicated relationship. This is done
while the query runs.
Remarks
If you use a one-to-one relationship, there will be no difference
between the one or many direction cross-filtering
You can use the CROSSFILTER function only when you want to take
filters as arguments. For instance, you can use the
CALCULATETABLE, CALCULATE,
CLOSINGBALANCEMONTH, CLOSINGBALANCEYEAR,
OPENINGBALANCEMONTH, CLOSINGBALANCEQUARTER,
OPENINGBALANCEQURATER, OPENINGBALANCEYEAR,
TOTALQTD, TOTALYTD and TOTALMTD
This function will use any existing relationship in the model and
identify the relationship based on the endpoint column
In this function, the cross-filtering setting in a relationship does not
hold any importance. You do not have to worry about whether the
relationship filter is set to one or two directions since this does not
affect the usage of that function. This function will always override
any cross-filtering settings
You will receive an error if the columns that you have named in the
arguments are not included in the relationships. You will also receive
an error if the arguments belong to different relationships
If you nest the CALCULATE expressions, and you include the
CROSSFILTER function in more than one CALCULATE expression,
the innermost CROSSFILTER will be the one that is used throughout
if there is any ambiguity
Example
= CALCULATE (Sales[Distinct Count of Products],
CROSSFILTER (Sales[Product],Products[Product],Both))
DISTINCT
This function will return a table with only one column. This column will contain
the distinct values that are present in a specified column. In simple words, this
function will remove any duplicate values and will only use the unique values in
the column. Remember that you will need to use the DISTINCT function within
a formula if you want to pass the distinct values into another function.
Syntax
DISTINCT (<column> )
Parameters
Sr.No. Parameter & Description
1 column
This parameter will be the column from where you need to return
unique values. You can also use an expression here that will return
the column to use.
Return Value
This function will return a column with unique values in it.
Remarks
The results of this function are always affected if there are any context filters in
the column. For instance, when you use the formula to create a calculated field,
the result of that field will never change even when a filter is applied to a region.
Example
= COUNTROWS (DISTINCT (Sales[Salesperson ID]))
EARLIER
This function will return the value that is present in the specified column in any
outer evaluation.
Syntax
EARLIER (<column>, <number>)
Parameters
Sr.No. Parameter & Description
1 column
This parameter is a column or a DAX expression that can be used to
resolve a column.
2 number
This parameter is optional and is a positive number that is sent to the
outer evaluation pass. The evaluation level is represented as one, the
next one as two, and so on. If you do not include this number, the
default value will be one.
Return Value
This function will return the current value in a row or column as the evaluation
passes.
Remarks
This function is always used for a nested calculation. When you use this
function, you do not want to use a specific value as an input. This function will
produce an output based on that input. If you use this function in Power BI or
Microsoft Excel, you can perform these calculations within the context of the
current row. In DAX, however, you will need first to store the value of the input
before you make the right calculation. This function is often used in the context
of columns. This function will succeed only when there is a row that is present
before the beginning of the table. It will otherwise throw an error.
Example
If you use a Sales table that includes sales data, you can then create a calculated
column using the rank of the amounts of sales in the following manner:
= COUNTROWS (
FILTER (Sales, EARLIER (Sales[Sales Amount])<Sales[Sales Amount])
)+1
EARLIEST
This function will return the current value of the column that is specified in the
function parameter. The function will run through the evaluation pass based on
the specified column.
Syntax
EARLIEST (<column>)
Parameters
Sr.No. Parameter & Description
1 column
This is a parameter that refers to a specific column in the data set .
Return Value
The function will return the value present in the current row in the column
selected. This value will be the one stored at the outermost evaluation pass.
Remarks
This function is much like the EARLIER function, but you can specify the level
of recursion that you want to include. The results of the EARLIER and
EARLIEST functions will be the same only if the number parameter in the
EARLIER function is set to one.
Example
If you want to use a Sales table that contains information about sales, you can
create a calculated column that will rank the sales amounts in the following
manner:
= COUNTROWS (
FILTER (Sales, EARLIEST (Sales[Sales Amount])>Sales[Sales Amount])
)+1
FILTER
This function will return a table that will represent a subset of an expression or
another table.
Syntax
FILTER (<table>, <filter>)
Parameters
Sr.No. Parameter & Description
1 table
This parameter is a table that you want to use. You can filter this
table to perform the necessary operations. You can either use a table
name or an expression that will result in a table.
2 filter
This parameter is a Boolean expression that you need to evaluate for
every row in the table.
Return Value
This function will return a table only with the data after a filter is applied.
Remarks
You can use the DAX filter function if you want to reduce the number of rows
present in the table you are using. You can use specific data from the columns to
perform any calculation. This function cannot be used independently, but it can
be used as a function that is embedded in different functions that use a table as
the argument.
Example
Medal Count Summer Sports:= COUNTAX (
FILTER (Results, Results[Season] = "Summer"), Results[Medal]
)
FILTERS
This function will return the values that are directly applied as a filter in the
columnName parameter.
Syntax
FILTERS (<columnName>)
Parameters
Sr.No. Parameter & Description
1 columnName
This parameter will name the column in a table. Remember, you
cannot use an expression in this parameter.
Return Value
This function will return a value that can be used to apply a filter to the selected
columnName.
Example
You can calculate the number of direct filters on a column using the following:
= COUNTROWS (FILTERS (Sales[Region]))
HASONEFILTER
This function will return the value TRUE if there is only one value in the
columnName that is filtered. Otherwise, this function will return the value
FALSE .
Syntax
HASONEFILTER (<columnName>)
Parameters
Sr.No. Parameter & Description
1 columnName
This parameter will take the name of a column in the table using the
DAX syntax. You cannot use an expression in this parameter.
Return Value
This function will return a Boolean value – TRUE or FALSE.
Remarks
This function is very similar to the HASONEVALUE function, with the
difference that this function will work on filters that have directly been applied
to the column. HASONEVALUE is a function that will work based on any cross-
filters that you use on the data.
Example
= HASONEFILTER (Sales[Product])
HASONEVALUE
This function will return the value TRUE if there is only one distinct value in the
column after a filter has been applied. Otherwise, it will return FALSE.
Syntax
HASONEVALUE (<columnName>)
Parameters
Sr.No. Parameter & Description
1 columnName
This parameter will name the column that can be used in this
function. Remember, you cannot use an expression.
Return Value
This function will return a Boolean result – TRUE or FALSE.
Example
= HASONEVALUE (Sales[Product])
ISCROSSFILTERED
This function will return the value TRUE when a column in the table selected or
a related table is filtered.
Syntax
ISCROSSFILTERED (<columnName>)
Parameters
Sr.No. Parameter & Description
1 columnName
This parameter is the name of the column in the table. You cannot
use an expression for this parameter.
Return Value
This function will return either TRUE or FALSE .
Remarks
Any column in the table is filtered if a filter is directly applied to the
column. You can use one or more filters on a column
The column columnName will be cross filtered if the filter is applied
to a different column either in the related table or the same table
You can also use this function if you want to find a column that has been filtered
directly.
Example
ISCROSSFILTERED (<columnName>)
ISFILTERED
This function is used to return TRUE is the columnName is filtered directly. If
there are no filters present on the columns or the column selected is filtered
because of a different column in this table or a related table, this function will
return FALSE.
Syntax
ISFILTERED (<columnName> )
Parameters
Sr.No. Term & Definition
1 columnName
This parameter is the name of the column present in a table, and you
must remember not to use an expression.
Return Value
This function will return the value TRUE or FALSE.
Remarks
Any column in the table is filtered if a filter is directly applied to the
column. You can use one or more filters on a column
The column columnName will be cross filtered if the filter is applied
to a different column either in the related table or the same table
You can also use this function if you want to find a column that has been filtered
directly.
Example
= ISFILTERED (Sales[Product])
KEEPFILTERS
This function is used to modify how the filters will be applied to the data while
you evaluate the CALCULATETABLE or CALCULATE function.
Syntax
KEEPFILTERS (<expression>)
Parameters
Sr.No. Term & Definition
1 Expression
This parameter uses any DAX expression.
Return Value
The function will not return any value.
Remarks
This function can be used within the CALCULATE or CALCULATETABLE
functions. this will allow you to override the standard behavior of these
functions. If you use this function, the existing filters in the current column will
be used in context with the other columns that use a similar first. The
intersection of these values will be used to evaluate the expression. You must
remember that both the sets of arguments will apply:
Return Value
This function will return a single value that is related to the current row.
Remarks
This function will require that a relationship must exist between any related table
and the current table based on the information required. You will need to specify
those columns that contain the data that you need. This function will follow an
existing relationship to help you fetch those values from any related table from
the specified column. If this function is used in a LOOKUP function, it will go
through all the values in the selected table regardless of the different filters that
could have been applied. This function will need a row context. You can use this
function in either of the following cases:
Return Value
This function will return a column that contains unique values alone.
Remarks
This function can be used as an intermediate function. It can be nested within a
different function to help you obtain the list of distinct values which can be
counted. You can also use the function to filter the values in a table or calculate
the sum of other values. If you use this function in a context where the column
has been filtered, like in a Pivot Table, the unique values returned will be
affected by these filters.
Example
= COUNTROWS (VALUES (Sales[Salesperson ID]))
This function will return the number of rows in the Sales table, where there are
unique Salesperson IDs.
Chapter Fourteen: Time Intelligence Functions
The Time Intelligence functions in DAX will allow you to create the right
calculations that will support the needs of any business intelligence analysis.
These functions will enable you to manipulate data in the table using periods like
days, weeks, months, quarters, or years.
CLOSINGBALANCEMONTH
This function will evaluate the expression in the current context on the last day
of the month.
Syntax
CLOSINGBALANCEMONTH (<expression>, <dates>, [<filter>])
Parameters
Sr.No. Parameter & Description
1 expression
This parameter is used to enter an expression that will return a scalar
value.
2 dates
This parameter will return a column that contains the dates.
3 filter
This parameter is optional and is an expression that is used to specify
the filter that you will apply to the data based on the current context.
Return Value
This function will return a scalar value.
Remarks
You can enter one of the following to define the dates parameter:
You cannot use any expression that will either scan a table or return a
table as a value, and this includes aggregate functions
You cannot use the CALCULATE function in this expression
You cannot use an expression using a calculated field
Boolean expressions can, however, use functions that will either calculate a
scalar value or look up a single value. You can either use a table expression or
Boolean expression in the filter parameter. This will define the filter that needs
to be used. If you filter the data, the context will change because of the function.
This will happen since the data will be filtered differently. The function will also
evaluate the expression in a new manner that you specify. For every column that
you use in the filter parameter, you should remove the existing columns and
apply the filter parameter instead.
Example
Month End Inventory Value:= CLOSINGBALANCEMONTH (
SUMX (ProductInventory, [UnitsBalance]*
[UnitCost]),ProductInventory[InventoryDate]
)
CLOSINGBALANCEQUARTER
This function is used to evaluate the expression in the current context one the
last date of the quarter.
Syntax
CLOSINGBALANCEQUARTER (<expression>, <dates>, [<filter>])
Parameters
Sr.No. Parameter & Description
1 expression
This parameter is the expression that will return a single scalar value.
2 dates
This parameter will contain the dates you are looking for.
3 filter
This parameter is optional, and you can include an expression that
will allow you to specify the filter you can use in the current
situation.
Return Value
This function will return the scalar value that will represent the expression that
has been evaluated. This expression will be evaluated based on the last date of
the quarter in the current context.
Remarks
You can enter one of the following to define the dates parameter:
You cannot use any expression that will either scan a table or return a
table as a value, and this includes aggregate functions
You cannot use the CALCULATE function in this expression
You cannot use an expression using a calculated field
Boolean expressions can, however, use functions that will either calculate a
scalar value or look up a single value. You can either use a table expression or
Boolean expression in the filter parameter. This will define the filter that needs
to be used. If you filter the data, the context will change because of the function.
This will happen since the data will be filtered differently. The function will also
evaluate the expression in a new manner that you specify. For every column that
you use in the filter parameter, you should remove the existing columns and
apply the filter parameter instead.
Example
Quarter End Inventory Value:=CLOSINGBALANCEQUARTER (
SUMX (ProductInventory,[UnitsBalance]*
[UnitCost]),ProductInventory[InventoryDate]
)
CLOSINGBALANCEYEAR
This function will evaluate an expression in the current context on the last day of
the year.
Syntax
CLOSINGBALANCEYEAR (<expression>, <dates>, [<filter>],
[<year_end_date>])
Parameters
Sr.No. Parameter & Description
1 expression
This parameter is an expression that will return a single scalar value.
2 dates
This parameter will list the name of the column that contains all the
dates.
3 filter
This is an optional parameter, and it is an expression that will specify
which filter should be applied.
4 year_end_date
This is an optional parameter and is a string literal with a date. This
literal will define the end date in the year. The default date is
December 31.
Return Value
This function will return a scalar value .
Remarks
You can enter one of the following to define the dates parameter:
You cannot use any expression that will either scan a table or return a
table as a value, and this includes aggregate functions
You cannot use the CALCULATE function in this expression
You cannot use an expression using a calculated field
Boolean expressions can, however, use functions that will either calculate a
scalar value or look up a single value. You can either use a table expression or
Boolean expression in the filter parameter. This will define the filter that needs
to be used. If you filter the data, the context will change because of the function.
This will happen since the data will be filtered differently. The function will also
evaluate the expression in a new manner that you specify. For every column that
you use in the filter parameter, you should remove the existing columns and
apply the filter parameter instead. The year_end_date parameter is a string literal
that represents the date. This parameter is found where the workbook is created.
During the debugging, the compiler will ignore the date section of the year.
Example
Year End Inventory Value:= CLOSINGBALANCEYEAR (
SUMX (ProductInventory, [UnitsBalance]*
[UnitCost]),ProductInventory[InventoryDate]
)
DATEADD
This function will return a table that will contain a single column with dates.
These dates will either be shifted backward or forward in time.
Syntax
DATEADD (<dates>, <number_of_intervals>, <interval>)
Parameters
Sr.No. Parameter & Description
1 dates
This parameter will take a column that contains a list of dates.
2 number_of_intervals
This parameter will contain a column that will contain a list of dates.
3 Interval
This parameter will use an interval by which the dates should be
shifted. The value can be any of the following:
Year
Quarter
Month
Day
Return Value
The function will return a table that will contain one column with dates.
Remarks
You can enter one of the following to define the dates parameter:
You cannot use any expression that will either scan a table or return a
table as a value, and this includes aggregate functions
You cannot use the CALCULATE function in this expression
You cannot use an expression using a calculated field
Boolean expressions can, however, use functions that will either calculate a
scalar value or look up a single value. You can either use a table expression or
Boolean expression in the filter parameter. This will define the filter that needs
to be used. If you filter the data, the context will change because of the function.
This will happen since the data will be filtered differently. The function will also
evaluate the expression in a new manner that you specify. For every column that
you use in the filter parameter, you should remove the existing columns and
apply the filter parameter instead. If the parameter number_of_intervals is
positive, the dates will move forward in time and will be shifted back if the
number is negative. The interval parameter is not a set of strings but an
enumeration. It is for this reason that you cannot enclose the values in these
intervals in quotation marks. The values, day, month, quarter, or year, should
always be written in full. This will result in the return of a table that will only
include the dates specified by the parameter dates.
Example
= DATEADD (ProductInventory[InventoryDate],1, YEAR )
DATESBETWEEN
This function will return a table with one column that will contain the dates that
either begins with the parameter start_date and continue to the end_date.
Syntax
DATESBETWEEN (<dates>, <start_date>, <end_date>)
Parameters
Sr.No. Parameter & Description
1 dates
This parameter is a column that contains dates.
2 start_date
A date expression.
3 end_date
A date expression.
Return Value
This function will return a table that contains one column with dates.
Remarks
The start_date parameter is the earliest value in the date column
The end_date parameter is the latest or last value in the date column
These date parameters are both inclusive. For example, let us assume
that you specify November 1 and December 31 as the start and end
dates, respectively. You have some sales that take place on November
1 and December 31; therefore, these sales will also be included since
the start and end date parameters are inclusive.
Example
= CALCULATE (
SUM (Sales[Sales Amount]), DATESBETWEEN (Sales[Date], DATE
(2015,1,1), DATE (2015,3,31))
)
DATESINPERIOD
This function will return a table with one column that contains dates. These dates
will begin with the start_date and will include all dates with an interval that is
specified by the parameter number_of_intervals.
Synta x
DATESINPERIOD (<dates>, <start_date>, <number_of_intervals>, <interval>)
Parameters
Sr.No. Parameter & Description
1 dates
This parameter is a column with dates.
2 start_date
A date expression.
3 number_of_intervals
This is an integer that specifies how many intervals should be added
or taken away from the dates.
4 interval
This parameter is an interval using which the dates will be shifted.
The value of this interval may be any of these:
year
quarter
month
day
Return Value
This function will return one column in a table with dates.
Remarks
You can enter one of the following to define the dates parameter:
You cannot use any expression that will either scan a table or return a
table as a value, and this includes aggregate functions
You cannot use the CALCULATE function in this expression
You cannot use an expression using a calculated field
Boolean expressions can, however, use functions that will either calculate a
scalar value or look up a single value. You can either use a table expression or
Boolean expression in the filter parameter. This will define the filter that needs
to be used. If you filter the data, the context will change because of the function.
This will happen since the data will be filtered differently. The function will also
evaluate the expression in a new manner that you specify. For every column that
you use in the filter parameter, you should remove the existing columns and
apply the filter parameter instead. If the parameter number_of_intervals is
positive, the dates will move forward in time and will be shifted back if negative.
The interval parameter is not a set of strings but an enumeration. It is for this
reason that you cannot enclose the values in these intervals in quote marks. The
values, day, month, quarter, or year, should always be written in full. This will
result in the return of a table that will only include the dates specified by the
parameter dates.
Example
= CALCULATE (
SUM (Sales [Sales Amount]),
DATESINPERIOD (Sales[Date], DATE (2015,1,1),3, MONTH)
)
Some similar functions are:
DATESMTD
DATESQTD
DATESYTD
ENDOFMONTH
This function will return the last date of the month that is in the context of the
current situation for a specific set of dates.
Syntax
ENDOFMONTH (<dates>)
Parameters
Sr.No. Parameter & Description
1 dates
This parameter will take a column of dates.
Return Value
This function will return a table that contains a single row and column with a
date.
Remarks
You can enter one of the following to define the dates parameter:
A Boolean expression that will define a table with a single column
containing information about date and time
A table expression that will return a table with one column consisting
of dates and times
A reference to any column containing dates and times
Some constraints on Boolean expressions are:
You cannot use any expression that will either scan a table or return a
table as a value, and this includes aggregate functions
You cannot use the CALCULATE function in this expression
You cannot use an expression using a calculated field
Boolean expressions can, however, use functions that will either calculate a
scalar value or look up a single value. You can either use a table expression or
Boolean expression in the filter parameter. This will define the filter that needs
to be used. If you filter the data, the context will change because of the function.
This will happen since the data will be filtered differently. The function will also
evaluate the expression in a new manner that you specify. For every column that
you use in the filter parameter, you should remove the existing columns and
apply the filter parameter instead.
Example
= ENDOFMONTH (Sales [Date])
Similar functions are:
ENDOFQUARTER
ENDOFYEAR
FIRSTDATE
This function will return the first date from a column of dates present in a table
in the current context.
Syntax
FIRSTDATE (<dates>)
Parameters
Sr.No. Parameter & Description
1 dates
This parameter is a column that will contain the dates.
Return Value
This function will return a table with one row and column with a value that is a
date.
Remarks
You can enter one of the following to define the dates parameter:
You cannot use any expression that will either scan a table or return a
table as a value, and this includes aggregate functions
You cannot use the CALCULATE function in this expression
You cannot use an expression using a calculated field
Boolean expressions can, however, use functions that will either calculate a
scalar value or look up a single value. You can either use a table expression or
Boolean expression in the filter parameter. If the current context is only one date,
the dates returned by this function and the LASTDATE function is the same.
This function will return a single row and column with the date in it. This value
can be used as a parameter in other functions that will require a parameter as a
table.
Example
= FIRSTDATE (Sales [Date])
The LASTDATE function is similar to this function.
FIRSTNONBLANK
This function will return the date in the column that is filtered based on the
current context. The value will only be returned when the expression is not
blank.
Syntax
FIRSTNONBLANK (<column>, <expression> )
Parameters
Sr.No. Parameter & Description
1 column
This parameter is an expression to return a column.
2 expression
This parameter is an expression that will evaluate a blank cell in the
column entered.
Return Value
This function will return a value that contains one row, a column, and a non-
blank value.
Remarks
You can enter one of the following to define the dates parameter:
You cannot use any expression that will either scan a table or return a
table as a value, and this includes aggregate functions
You cannot use the CALCULATE function in this expression
You cannot use an expression using a calculated field
Boolean expressions can, however, use functions that will either calculate a
scalar value or look up a single value. You can either use a table expression or
Boolean expression in the column parameter, which will return a scalar value.
Example
= FIRSTNONBLANK (Sales [Sales Amount], MIN (Sales [Date])>3/31/2015)
The LASTNONBLANK is a similar function.
Chapter Fifteen: Tips to Using Power BI
Now that we have covered the basics of Power BI and also gathered some
information about DAX let us look at some tips that will help you work better
with Power BI.
Keep the Visualization Simple
Through Power BI, you can deliver a message about the data. As mentioned
earlier, there are numerous visualization tools you can use in Power BI. These
visualization tools are present in the gallery. Some of these are very complex,
and they can show you the relationship between data variables in a way that will
make sense to you.
Selecting the Right Chart
It is easy for an analyst to know which chart they need to select to explain the
data. They can also look at complex charts and understand what is being said.
When it comes to the other section of people, it is all about keeping things
simple, clear, and easy to understand. So, you need to focus on simplicity. You
can use a simple line or bar chart in most cases, and you can use ugly tables if
needed. These are the best way to represent any raw data. This is sometimes all
you need to do. For instance, some people avoid using treemaps and pie charts
for the simplest of reasons – they cannot see any difference in the sections or
fields where there are similar values. Let us look at the following example. We
are trying to report the volume of sales per region. Look at the image below and
check whether orange or red is bigger. See if you can find a difference.
If you look at the image above, you cannot find a difference in the fields
representing North America (orange) and Europe (red). Now, look at the image
below.
This is clearer, isn’t it? This report is showing you exactly what the pie chart did,
except that we have converted the pie fields into columns. You can also see the
difference between the sales in North America (orange) and Europe (red) easily.
Some Thumb Rules
People often read any information from top to bottom, so you should
always put the most relevant information at the top
You can use vertical bars to display data. you should always use
sorted data since it is easy to read
You can use horizontal bars for ranking variables in a data set
A line chart will work best for a time series tracker wherever you
need to compare different series in data. You can also use single bars
if needed
You can use a line and bar chart to represent values of different kinds
You can use bubble charts to present three different values
Identify the Context
Power BI allows you to use the cross-filtering feature to understand data better.
When you create charts, you can connect the data set to those charts. So, when
you do filter one data set, you will see that the other data set has also been
filtered. This will make it easier for you to compare the data since you can drill
down and perform simple analysis.
Using Filters in Power BI
What you may not know is that there are three ways in which you can connect
and filter data. This will make it easier for you to analyze data. Let us consider a
project management example. You want to see the names of the people against
the time reported by them and the time they have reported for every month. You
can then see how the interaction will change the way the data is depicted.
Types of Interactions
None
Here you do not add any filtering to the elements in the data set. You can use this
if you want to display the data to say that it is not affected by any change in the
behavior of the user. In this example, you will see that you cannot see any
influence data at the bottom of the chart since you do not want to look at any
interactions.
The above image shows that the data is never affected by the user’s behavior.
When you click on the bar at the top, it will not change the display of the bars at
the bottom.
Highlight
The value that you filter on will be displayed in the form of the context. You
should use this when you want to see what percentage of the total is formed by
the selected element. When you click on the bar at the top, the chart will fade out
at the bottom. The only part of the bar chart will be the bar that is represented by
the clicked element .
Filter
In this interaction, you will display the value that is actually filtered. You should
use this only when you want to see what is hidden behind the element that you
have filtered on. In this form of interaction, you only want to look at the detailed
information and not how it is related to other data elements. In the example
below, when you click on the bar in the chart filters for the top chart, you will
see that the only data applicable in the bottom chart is for the element that you
have filtered on.
You should choose the type of interaction you want to include depending on the
context that you are looking at since the relationship between the data sets will
have an impact on your data. If there are too many data elements, it will affect
the report. You may also find it hard to create a report in Power BI .
Slice, Dice, and Filter
This is a very basic concept of data visualization. You will still be surprised at
how many different filtering options are present in Power BI. Let us look at the
five most obvious ones:
Basic Filters
Visual Level Filter
This filter will only filter the selected data at a visual level. This is a useful
option to use if you want to include some background data that you can only use
for filtering.
Page-Level Filter
This filter will be applied to every element present in the page.
Report Level Filter
This filter will be applied to all data elements across all pages. It is a useful filter
to use if you want to see how the data works with other elements across different
pages in the report. You will, however, have a different view on every page.
When you select your filter and move to the next page in the report, the filter
will still stay selected. This will allow you to view the data in the same context
across all pages.
Slicers
A slicer is a filter that is available as a single or multiple selection in a dropdown
or checkbox. Most people do not find this very useful since they take up space
on the canvas. These slicers do not provide too much value addition since you
can use cross-filtering to understand your data better. A slicer will only work on
one page. This means that if you set up a slicer on a specific page, it will only
work on that page. It is for this reason that this filtering option is limiting. When
you move to a different page, you will lose the context of all the data that you
worked with on the previous page.
Cross-Filtering
We have covered this in the previous point. The idea behind cross-filtering is
that it can be used to look at how the data interacts with each other. It is a better
idea to use this option instead of a slicer.
Let us continue with the project management example. You can use a multiple
page report with different pages that will show you an overview of the number
of hours or the details about the time taken by the user to complete tasks. if you
use a slicer or cross-filter, you will also need to include the project that you want
to look at on individual pages. If you use report filters, the project will be
selected even when you move to a different page in the report. Let us assume
you have seven pages in the report. Use either of these or see what is best for
you.
Hierarchies
A hierarchy is one of the best ways to show analysis on different levels of
granularity using the same charts or tools to visualize the data. For example, if
you are a program manager, you may be interested in different projects and want
to know how they are progressing every month. If you are a project manager,
you will be interested to know what is happening every week or every day. You
want to pay close attention to what is happening. You can always create different
reports for a project or program manager. You will, however, need to support a
large number of these cases. If you are clever, you will want to design a report in
a way that it can be used by both a program and project manager. This is where a
hierarchy comes into the picture.
Using Hierarchies in Power BI
You can use hierarchies in Power BI in three ways:
These hierarchies can directly come from the data source, which
means that the hierarchy is present in the data set
These hierarchies can be based either on time or date data. In Power
BI, you can represent the data in terms of days, months, or years. We
have looked at the various DAX functions you can use in the previous
chapter
You can add more dimensions to the data set and to the visualization.
This will not make these dimensions visible, but it will allow you to
drill down from one to the other
When you have a chart ready, you should look at the small arrows at the corner
of the chart, which will enable you to go through the hierarchy levels.
You can use this report and visualization to understand the data from different
views. Since one can create reports quickly in Power BI, you will be tempted to
create many reports since you can do this easily. You should, however, think of
those users who will use these reports. Think about how confused they will be
when you need to obtain tons of pages or reports to show similar information.
Think About the Message
When you share the report with people and allow them to edit the report, you
may end up with an analytical painting that has too many colors but absolutely
no information in it. Power BI allows you to produce a variety of charts and
tables to show your data set. This will make people want to create numerous
reports. The reporting canvas in Power BI is much like a slide in PowerPoint.
There is no pagination and scrolling. This is, however, the whole point. When
you begin to work on a report in Power BI, you should look at how you can fit
the charts on the reporting page and how you can visualize the information in
that space. You should remember that the message should be clear and easy for
anybody to digest. This is especially important when you look at the two display
areas in Power BI.
Dashboard
A dashboard is the primary point where you will go and work on your analysis.
You cannot work with interactions or filters. A tile in the dashboard will link one
report to another to present the data easily.
Reports
A report is an analytical space with various capabilities. The purpose is to dig
into the details and also understand why specific things happen using the data.
Let us look at the following example shared by Microsoft.
This dashboard uses some sample information about sales opportunities, and it
will show the same data in numerous ways.
What Are We Looking At?
Remember, this dashboard is only a demo dashboard that Microsoft developed.
It cannot be used anywhere in particular. This is an example of bad practices.
Every tile in the dashboard shows the same data from a different perspective.
This will make the dashboard an analytical space and not the status space. Think
about how you can simplify this based on the main concepts – volume and actual
opportunities number.
This dashboard will only show the number and volume of actual opportunities.
This is the most important data that you should consider. You can not only see
this data better, but you also have enough space that will allow you to add more
meaningful information about the data set. If you want to learn more about the
data displayed on the dashboard, you should only click on the tile to obtain the
report. This will allow you to see the data in the original dashboard.
Conclusion
Power BI is a data visualization tool that is used by numerous businesses across
the globe. This tool has replaced data visualization tools like Tableau since it is
cheaper to use. Businesses can connect to a variety of data sources and also
allows you to work with the cloud. Throughout this book, you will learn
everything you need to about Power BI. You will also learn more about the DAX
language and how you can use it to automate the visualization process.
References
https://www.tutorialspoint.com/
https://www.digitalvidya.com/blog/introduction-to-microsoft-power-bi/
https://us.hitachi-solutions.com/blog/8-reasons-why-you-should-shift-reporting-
from-excel-to-power-bi /