SELECTEDMEASURE DAX Function (Information)

Returns the measure that is currently being evaluated.

Syntax

SELECTEDMEASURE ( )

This expression has no parameters.

Return values

Scalar A single value of any type.

A reference to the measure that is currently in context when the calculation item is evaluated.

» 5 related articles
» 1 related function

Examples

-- Code of the calculation item Growth in the Time calc
-- calculation group used in the following example.
IF (
    NOT ISSELECTEDMEASURE ( [Pct over all prods] ),
    VAR CY =
        SELECTEDMEASURE ()
    VAR PY =
        CALCULATE (
            SELECTEDMEASURE (),
            SAMEPERIODLASTYEAR ( 'Date'[Date] )
        )
    VAR Result = CY - PY
    RETURN
        Result
)
--  SELECTEDMEASURE is a placeholder used in calculation items
--  to represent the measure currently being modified by the
--  calculation item.
--
--  During the application process, each reference to SELECTEDMEASURE
--  is replaced with the currently selected measure
DEFINE
    MEASURE Sales[Sales Amount] =
        SUMX ( Sales, Sales[Quantity] * Sales[Net Price] )
    MEASURE Sales[Sales Quantity] =
        SUM ( Sales[Quantity] )
EVALUATE
SUMMARIZECOLUMNS (
    'Date'[Calendar Year],
    'Time calc'[Time calc],
    TREATAS ( { "CY 2008" }, 'Date'[Calendar Year] ),
    "Sales Amount", [Sales Amount],
    "Quantity", [Sales Quantity]
)
ORDER BY
    'Date'[Calendar Year],
    'Time calc'[Time calc]
Calendar Year Time calc Sales Amount Quantity
2008-01-01 Current 9,927,582.99 40,226.00
2008-01-01 Growth -1,382,363.13 -4,084.00
2008-01-01 Growth % -0.12 -0.09
2008-01-01 Prev Year 11,309,946.12 44,310.00

Related articles

Learn more about SELECTEDMEASURE in the following articles:

  • Introducing Calculation Groups

    This article is the first of a series dedicated to calculation groups in DAX. This introduction explains the capabilities of this feature and how to create calculation groups in a Tabular model. » Read more

  • Understanding Calculation Groups

    This article explores the properties of calculation groups in detail and then it describes how a calculation item is applied to a measure. Before starting, we suggest you read the previous article that introduces calculation groups. » Read more

  • Understanding the Application of Calculation Items

    This article explains how calculation items are applied to measure references, and it is part of a series dedicated to calculation groups in DAX. Before starting, we suggest you read the previous articles in this series. » Read more

  • Understanding Calculation Group Precedence

    This article explains the precedence of calculation groups in DAX, needed whenever multiple calculation groups are present within the same model. Before starting, we suggest you read the previous articles in this series. » Read more

  • Avoiding Pitfalls in Calculation Groups Precedence

    This article describes in which conditions the precedence of calculation groups might return unexpected results when filtering calculation items in both the visuals and the measures present in a report. » Read more

Related functions

Other related functions are:

Last update: Apr 2, 2021   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo

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

2018-2021 © 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.

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