DETAILROWS DAX Function (Table manipulation)  Context Transition

Returns the table data corresponding to the DetailRows expression defined on the specified Measure. If a DetailRows expression is not defined then the entire table to which the Measure belongs is returned.

Syntax

DETAILROWS ( <Measure> )
Parameter Attributes Description
Measure

A Measure reference whose DetailRows expression is to be evaluated.

Return values

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

Remarks

IMPORTANT : DETAILROWS should perform a context transition, but in SSAS 2017 it does not do that. The behavior by design is to perform a context transition, and this should be fixed in upcoming hotfix or service packs. As a workaround, if called in a row context, it should be wrapped in a CALCULATETABLE statement. Do not use in a row context if the intended behavior should not execute the context transition – assign the result of DETAILROWS in a variable before the iterator in that case.

» 2 related articles

Examples

Consider the following Detail Rows Expression in the Sales Amount measure:

SELECTCOLUMNS (
    Sales,
    "Order Number", Sales[Order Number],
    "Order Line Number", Sales[Order Line Number],
    "Customer", RELATED ( Customer[Name] ),
    "Product", RELATED ( 'Product'[Product Name] ),
    "Quantity", Sales[Quantity],
    "Line Amount", Sales[Quantity] * Sales[Net Price]
)

DETAILSROWS invokes the Detail Rows Expression for the corresponding measure in the same filter context.

-- Show DETAILROWS for transactions made in one day 
EVALUATE
CALCULATETABLE (
    DETAILROWS ( [Sales Amount] ),
    'Date'[Date] = DATE ( 2007, 9, 19 ),
    Customer[Customer Type] = "Person"
)
Order Number Order Line Number Customer Product Quantity Line Amount
20070919123935 1 Barnes, Alexis Contoso 512MB MP3 Player E51 Blue 1 11.69
20070919123937 1 Ruiz, Eddie Contoso 512MB MP3 Player E51 Blue 1 11.69
20070919123941 1 Anderson, Eduardo Contoso 512MB MP3 Player E51 Blue 1 11.69
20070919427828 1 Gao, Ernest Fabrikam Social Videographer 2/3” 17mm E100 Grey 1 144.00
20070919712464 1 Cook, Jared MGS Rise of Nations2009 E152 1 38.70
20070919712465 1 Patel, Cassandra MGS Rise of Nations2009 E152 1 38.70
20070919712466 1 He, Willie MGS Rise of Nations2009 E152 1 38.70
20070919712467 1 Jones, Jennifer MGS Rise of Nations2009 E152 1 38.70
20070919525616 1 Rubio, J├ęsus The Phone Company Touch Screen Phones – CRT M11 Grey 1 170.10
20070919525617 1 Shan, Leonard The Phone Company Touch Screen Phones – CRT M11 Grey 1 170.10
20070919525618 1 Hernandez, Albert The Phone Company Touch Screen Phones – CRT M11 Grey 1 170.10
20070919123936 1 Vazquez, Monique Contoso 512MB MP3 Player E51 Blue 4 46.76
20070919525615 1 Hall, Destiny The Phone Company Touch Screen Phones – CRT M11 Grey 4 680.40

Related articles

Learn more about DETAILROWS in the following articles:

Last update: Mar 5, 2021   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo

2018-2021 © SQLBI. All rights are reserved. Information coming from MSDN 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.

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 DETAILROWS? 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.