RELATEDTABLE Function (DAX)

Evaluates a table expression in a context modified by the given filters.

Syntax

RELATEDTABLE(<expression>,<filter1>,<filter2>,…)

Parameters

Term

Definition

expression

The table expression to be evaluated

filter1,filter2,…

A Boolean expression or a table expression that defines a filter

The expression used as the first parameter must be a table or an expression that returns a table.

The following restrictions apply to Boolean expressions that are used as arguments:

  • The expression cannot reference a measure.

  • The expression cannot use a nested CALCULATE function.

  • The expression cannot use any function that scans a table or returns a table, including aggregation functions.

However, a Boolean expression can use any function that looks up a single value, or that calculates a scalar value.

Return Value

A table of values.

Remarks

The RELATEDTETABLE function changes the context in which the data is filtered, and evaluates the expression in the new context that you specify. For each column used in a filter argument, any existing filters on that column are removed, and the filter used in the filter argument is applied instead.

This function is a synonym for CALCULATETABLE function.

Example

The following example uses the RELATEDTABLE function to get Internet Sales for 2002; this value is later used to calculate a ratio of sales compared to the sales in year 2002.

The following table shows the results of using the code shown here.

Row Labels

Internet SalesAmount_USD

RelatedTable 2002 Internet Sales

Internet Sales to 2002 ratio

2001

$2,627,031.40

$5,681,440.58

0.46

2002

$5,681,440.58

$5,681,440.58

1.00

2003

$8,705,066.67

$5,681,440.58

1.53

2004

$9,041,288.80

$5,681,440.58

1.59

Grand Total

$26,054,827.45

$5,681,440.58

4.59

= SUMX( RELATEDTABLE('InternetSales_USD', 'DateTime'[CalendarYear]=2002)
     , [SalesAmount_USD])