locked
DAX Scope() ? RRS feed

  • Question

  • Hi,

    If I have measures that implement different behaviors (different calculations) depending on their context, what would be the best way to do this in DAX?

    More specifically I have a dimension with 3 members, A, B, and C.

    When using Measure on these members, I want to implement different behavior on each on. Ie. A = RawMeasure, B = RawMeasure - Measure2, C = RawMeasure / Measure3.

    Just an example. This would be easy to do in MDX but I'm not sure how to go around this in DAX? Please advice.

    Thanks.

    Wednesday, May 22, 2013 2:04 PM

Answers

  • SCOPEs are currently not supported for tabular models/DAX

    so you can only define calculation logic within calculated measures
    in your case you may want to use a logic like this:

    MyMeasure:=SWITCH(VALUES(table[mycalculation],
    "A", [RawMeasure],
    "B", [RawMeasure] - [Measure2],
    "C", [RawMeasure] / [Measure3]
    )

    you may also want to check for HASONEVALUE() first otherwise you will get an error if nothing is selected

    hth,
    gerhard


    - www.pmOne.com -

    • Proposed as answer by Elvis Long Friday, May 24, 2013 2:53 AM
    • Marked as answer by Elvis Long Thursday, May 30, 2013 1:44 AM
    Thursday, May 23, 2013 12:18 PM
    Answerer