192 Practical PowerPivot & DAX Formulas for Excel 2010
T
his is a wide-ranging chapter on some of the fundamental DAX functions.
It includes syntax and examples for all of the Filter functions and all of the
Logical functions. In addition, it discusses some other functions—for example,
those that are often referred to as Information or IS() functions. An example is
ISBLANK(). There is also one Text function, BLANK(), which has been added here
because of its close relationship to ISBLANK(). The Filter functions, in particular, are
extremely powerful. Among other things, they allow you to override the filter context that
a user chooses in a pivot table. They help to display classic BI values such as “percentage of
parent” or “percentage of all.” Some of the examples are shown as calculated columns,
others as measures. With measures, in particular, your results may differ from those
shown in the screenshots, as there are a few different incarnations of Northwind—not
always with the same data!
C
Key concepts Filtering data, overriding and changing filter context, denormalizing
data, testing data, conditional testing, examining data, dealing with errors
C
Keywords ALL(), ALLEXCEPT(), ALLNOBLANKROW(), AND(), BLANK(),
CALCULATE(), CALCULATETABLE(), DISTINCT(), EARLIER(), EARLIEST(),
FALSE(), FILTER(), IF(), IFERROR(), ISBLANK(), ISERROR(),
ISLOGICAL(), ISNONTEXT(), ISNUMBER(), ISTEXT(), NOT(), OR(),
RELATED(), RELATEDTABLE(), TRUE(), VALUES()
C
Preparation Some of the examples in this chapter (and all the other chapters
on DAX functions) refer to calculated columns created earlier on our Northwind
sample. If you don’t have Northwind data in a PowerPivot model, instructions of
how to import Northwind from SQL Server are given in Chapter 1. If you do not
have SQL Server or SQL Server Northwind, you may want to import the Access
version of Northwind—instructions are in Chapter 2. Alternatively, you can
download an Excel version of Northwind from this book’s Web site—if you do,
you’ll need to set up relationships between the tables, and again, Chapter 2 shows
you how. e calculated columns you’ll need, if you want to try out the examples,
were created in Chapter 1 and Chapter 2. As a reminder, they are the Year column
in the Orders table, the Sales Amount column in the Order Details table, and the
Category column in the Products table. Here are their respective DAX formulas:
=YEAR(Orders[OrderDate])
='Order Details'[Quantity] * 'Order Details'[UnitPrice]
=RELATED(Categories[CategoryName])
ALL() 1/7
ALL() can be used to modify the filter context of a measure. Consequently, the
examples over the next few pages concentrate on measures. In particular, ALL() is
frequently used to modify the filter context for a CALCULATE() function. As such,