RELATEDTABLE DAX Function (Relationships management)  Context Transition

Returns the related tables filtered so that it only includes the related rows.

Syntax

RELATEDTABLE ( <Table> )
Parameter Attributes Description
Table

The table that contains the desired value.

Return values

Table An entire table or a table with one or more columns.

A table of values.

Remarks

The RELATEDTABLE function performs a context transition from row context(s) to a filter context, and evaluates the expression in the resulting filter context.
This function is a shortcut for CALCULATETABLE function with no additional filters, accepting only a table reference and not a table expression.

» 4 related articles
» 1 related function

Examples

--  RELATEDTABLE is an alias - albeit limited - of CALCULATETABLE
DEFINE
    MEASURE Sales[Sales Amount] =
        SUMX ( Sales, Sales[Quantity] * Sales[Net Price] )
    MEASURE Sales[TX/Customer w/rel] =
        AVERAGEX ( Customer, COUNTROWS ( RELATEDTABLE ( Sales ) ) )
    MEASURE Sales[TX/Customer w/calc] =
        AVERAGEX ( Customer, COUNTROWS ( CALCULATETABLE ( Sales ) ) )

EVALUATE
SUMMARIZECOLUMNS (
    'Date'[Calendar Year],
    "Sales Amount", [Sales Amount],
    "TX/Customer w/rel", [TX/Customer w/rel],
    "TX/Customer w/calc", [TX/Customer w/calc]
)

Calendar Year Sales Amount TX/Customer w/rel TX/Customer w/calc
CY 2007 11,309,946.12 3.96 3.96
CY 2008 9,927,582.99 8.23 8.23
CY 2009 9,353,814.87 14.55 14.55

Related articles

Learn more about RELATEDTABLE in the following articles:

  • Row Context and Filter Context in DAX

    Understanding the difference between row context and filter context is important in using DAX correctly. This article introduces these two concepts. » Read more

  • Understanding Context Transition

    The context transition in DAX is the transformation of row contexts into an equivalent filter context performed by CALCULATE and CALCULATETABLE. Managing this behavior is the next step in learning DAX once you understand row context and filter context. This article provides the basics of context transition. » Read more

  • Using join functions in DAX

    This article describes the practical uses of NATURALLEFTOUTERJOIN and NATURALINNERJOIN in DAX. These functions are not commonly used in DAX because they do not have the same flexibility as the corresponding concepts in SQL. » Read more

  • Using RELATED and RELATEDTABLE in DAX

    RELATED and its companion function RELATEDTABLE, are two common DAX functions that are required when using a row context with relationships. In this article we describe why and when to use these two functions. » Read more

Related functions

Other related functions are:

Last update: Mar 13, 2024   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo, Pär Adeen

Microsoft documentation: https://docs.microsoft.com/en-us/dax/relatedtable-function-dax

2018-2024 © SQLBI. All rights are reserved. Information coming from Microsoft documentation is property of Microsoft Corp. » Contact us   » Privacy Policy & Cookies

Context Transition

This function performs a Context Transition if called in a Row Context. Click to read more.

Row Context

This expression is executed in a Row Context. Click to read more.

Iterator

Not recommended

The use of this function is not recommended. See Remarks and Related functions for alternatives.

Not recommended

The use of this parameter is not recommended.

Deprecated

This function is deprecated. Jump to the Alternatives section to see the function to use.

Volatile

A volatile function may return a different result every time you call it, even if you provide the same arguments. Click to read more.

Deprecated

This parameter is deprecated and its use is not recommended.

DirectQuery compatibility

Limitations are placed on DAX expressions allowed in measures and calculated columns.
The state below shows the DirectQuery compatibility of the DAX function.

Contribute

Want to improve the content of RELATEDTABLE? Did you find any issue?
Please, report it us! All submissions will be evaluated for possible updates of the content.


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.