0% found this document useful (0 votes)
80 views

More On DAX - Using Advanced DAX Functions - DAT206x Courseware - EdX

Advanced DAX

Uploaded by

Herman Bonou
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views

More On DAX - Using Advanced DAX Functions - DAT206x Courseware - EdX

Advanced DAX

Uploaded by

Herman Bonou
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

More on DAX | Using Advanced DAX Functions | DAT206x Courseware | edX 2018/10/22, 17)31

Microsoft: DAT206x
Analyzing and Visualizing Data with Excel

Help Taiwancoolboy !

Course ∠ Module 5 ∠ Using Advanced DAX Functions ∠ More on DAX

More on DAX
DAX Functions
Functions are predefined formulas that perform calculations by using specific
values, called arguments, in a particular order or structure. Arguments can be
other functions, another formula, column references, numbers, text, logical
values such as TRUE or FALSE, or constants.

DAX includes the following categories of functions: Date and Time, Information,
Logical, Mathematical, Statistical, Text, and Time Intelligence Functions. If you are
familiar with functions in Excel formulas, many of the functions in DAX will
appear similar to you; however, DAX functions are unique in the following ways:

A DAX function always references a complete column or a table. If you want to


use only particular values from a table or column, you can add filters to the
formula.

If you need to customize calculations on a row-by-row basis, DAX provides


functions that let you use the current row value or a related value as a kind of
argument, to perform calculations that vary by context. You will learn more
about context later.

DAX includes many functions that return a table rather than a value. The table
is not displayed, but is used to provide input to other functions. For example,
you can retrieve a table and then count the distinct values in it, or calculate
dynamic sums across filtered tables or columns.

https://courses.edx.org/courses/course-v1)Microsoft+DAT206x+3T2…e99f54dd43d949eb5/8fa35ffd65e249c589e595ba6ffe4af6/?child=first Page 1 of 5
More on DAX | Using Advanced DAX Functions | DAT206x Courseware | edX 2018/10/22, 17)31

DAX includes a variety of time intelligence functions. These functions let you
define or select date ranges, and perform dynamic calculations based on
them. For example, you can compare sums across parallel periods.

Sometimes it is difficult to know which functions you might need to use in a


formula. Excel includes the Insert Function feature, a dialog box that helps you
select functions by category and provides short descriptions for each function.

Add a function to a formula by using Insert Function

1. In the FactSales table, scroll to the right-most column, and then in the column
header, click Add Column.

2. In the formula bar, type an equals sign, =.

3. Click the Insert Function button. This opens the Insert


Function dialog box.

4. In the Insert Function dialog box, click the Select a category list box. By default,
All is selected, and all of the functions in the All category are listed below.
That’s a lot of functions, so you will want to filter the functions to make it
easier to locate the type of function you are looking for.

Context

https://courses.edx.org/courses/course-v1)Microsoft+DAT206x+3T2…99f54dd43d949eb5/8fa35ffd65e249c589e595ba6ffe4af6/?child=first Page 2 of 5
More on DAX | Using Advanced DAX Functions | DAT206x Courseware | edX 2018/10/22, 17)31

Context is one of the most important DAX concepts to understand. There are
two types of context in DAX; row context and filter context. We will first look at
row context.

Row Context
Row context is most easily thought of as the current row. For example, let's
assume we have a simple DAX formula used to create new data (named Margin)
for each row in a calculated column, defined as follows: Margin:=[SalesAmount]-
[TotalCost]. The formula =[SalesAmount] - [TotalCost] calculates a value in the
Margin column for each row in the table. Values for each row are calculated from
values in two other columns, [SalesAmount] and [TotalCost] in the same row.
DAX can calculate the values for each row in the Margin column because it has
the context: For each row, it takes values in the [TotalCost] column and subtracts
them from values in the [SalesAmount] column.

Row context doesn’t just apply to calculated columns. Row context also applies
whenever a formula has a function that applies filters to identify a single row in a
table. The function will inherently apply a row context for each row of the table
over which it is filtering. This type of row context most often applies to calculated
fields.

Filter Context
Filter context is a little more difficult to understand than row context. You can
most easily think of filter context as: One or more filters applied in a calculation
that determines a result or value.

Filter context does not exist in place of row context; rather, it applies in addition
to row context. For example, to further narrow down the values to include in a
calculation, you can apply a filter context which not only specifies the row
context, but also specifies only a particular value (filter) in that row context.

Filter context is easily seen in pivot tables. For example, when you add TotalCost
to the Values area, and then add Year and Region to the Row or Columns, you
are defining a filter context that selects a subset of data based on a given year
and region.

https://courses.edx.org/courses/course-v1)Microsoft+DAT206x+3T2…99f54dd43d949eb5/8fa35ffd65e249c589e595ba6ffe4af6/?child=first Page 3 of 5
More on DAX | Using Advanced DAX Functions | DAT206x Courseware | edX 2018/10/22, 17)31

Why is filter context so important to DAX? Because, while filter context can most
easily be applied by adding column and row labels and slicers in a PivotTable,
filter context can also be applied in a DAX formula by defining a filter using
functions such as ALL, RELATED, FILTER, CALCULATE, by relationships, and by
other calculated fields and columns. For example, let’s look at the following
formula in a calculated field named StoreSales:

Clearly this formula is more complex than some of the other formulas you’ve
seen. However, to better understand this formula, we can break it down, much
like we’ve done with other formulas.

This formula includes the following syntax elements:

A. The calculated field name StoreSales, followed by a colon :.

B. The equals sign operator (=) indicates the beginning of the formula.

C. The CALCULATE function evaluates an expression, as an argument, in a


context that is modified by the specified filters.

D. Parenthesis () surround one or more arguments.

E. A calculated field [Sales] in the same table as an expression. The Sales


calculated field has the formula: =SUM(FactSales[SalesAmount]).

F. A comma (,) separates each filter.

G. The referenced column and a particular value, DimChannel[ChannelName]


=”Store”, as a filter.

https://courses.edx.org/courses/course-v1)Microsoft+DAT206x+3T2…99f54dd43d949eb5/8fa35ffd65e249c589e595ba6ffe4af6/?child=first Page 4 of 5
More on DAX | Using Advanced DAX Functions | DAT206x Courseware | edX 2018/10/22, 17)31

This formula will ensure only sales values, defined by the Sales calculated field,
as a filter, are calculated only for rows in the DimChannel[ChannelName] column
with the value “Store”, as a filter.

As you can imagine, being able to define filter context within a formula has
immense and powerful capability. Being able to reference only a particular value
in a related table is just one such example. Don’t worry if you do not completely
understand context right away. As you create your own formulas, you will better
understand context and why it is so important in DAX.

To learn more about DAX, check out the following resources:

The DAX Resource Center Wiki


(http://social.technet.microsoft.com/wiki/contents/articles/dax-resource-
center.aspx).

Data Analysis Expressions (DAX) Reference (https://support.office.com/en-


us/article/Data-Analysis-Expressions-DAX-Reference-411c6891-614d-438c-
bf45-c7e061dd9e08).

The DAX in the BI Tabular Model whitepaper (https://aka.ms/edx-dat206x-pbi).

Discussion Hide Discussion


Topic: Module 5 / More on DAX

Add a Post

Show all posts by recent activity

There are no posts in this topic yet.

Learn About Verified Certificates


© All Rights Reserved

https://courses.edx.org/courses/course-v1)Microsoft+DAT206x+3T2…99f54dd43d949eb5/8fa35ffd65e249c589e595ba6ffe4af6/?child=first Page 5 of 5

You might also like