
222 Practical PowerPivot & DAX Formulas for Excel 2010
RELATED() is a Filter function. The first two examples are calculated columns on
the Orders table. The third example is a calculated column on the Order Details table,
the result of which is not shown in the screenshot.
Syntax
=RELATED(Employees[LastName])
=RELATED('Order Details'[Quantity])
=RELATED(Employees[LastName])
Result
Analysis
The first example returns the employee responsible for a particular order. It’s getting
data from another table. In order for this to work, you must have defined a relationship
between the two tables involved. Setting up relationships was examined in Chapter 2
and in Chapter 3. The RELATED() function must appear in the table on the many side
of a relationship—it’s doing a lookup of a value. The second example fails because, this
time, the Orders table is on the one side of the relationship. The third example will
work—it’s jumping tables. The starting point is the Order Details table. This is related
to the Orders table, which, in turn, is related to the Employees table. The net effect is to
show the employee responsible for each order line.
RELATEDTABLE()
RELATED() must appear in a table on the many side of a relationship. RELATEDTABLE()
can appear in either the many-side or the one-side table in a relationship. Generally, it is
more useful on the one side. As it returns a table, it can’t be used directly. Instead, it’s fed