Dax help: Shadow context with allselected()

  • I created this measure using the allselected function.

    Could you post the code for it? Something like

    DIVIDE ( [Total Sales], CALCULATE([Total Sales], ALLSELECTED('Calendar'[Month]))
  • Hello

    Thanks for your help.

    The first measure is ExpoWeight_PTF.

    This measure works well.

    But there is another measure which used the first measure. And the second measure have wrong result because of the shadow context of AllSelected function. Do you know how to work around this shadow context issue ?

    CT_Zspread_PTF

    SUMX('Position',[ExpoWeight_PTF] * related('Security'[SEC_Zspread]))

     

    ExpoWeight_PTF = VAR CurrentExposureVal = [SEC_Exposure_PTF]
    VAR ParentAssetVal =

    CALCULATE([SEC_MarketValue_PTF], ALLSELECTED())

    RETURN

    DIVIDE (CurrentExposureVal, ParentAssetVal)
  • Hello

    Thanks for your help.

    The first measure is ExpoWeight_PTF.

    This measure works well.

    But there is another measure which used the first measure. And the second measure have wrong result because of the shadow context of AllSelected function. Do you know how to work around this shadow context issue ?

    CT_Zspread_PTF

    SUMX('Position',[ExpoWeight_PTF] * related('Security'[SEC_Zspread]))

     

    ExpoWeight_PTF = VAR CurrentExposureVal = [SEC_Exposure_PTF]
    VAR ParentAssetVal =

    CALCULATE([SEC_MarketValue_PTF], ALLSELECTED())

    RETURN

    DIVIDE (CurrentExposureVal, ParentAssetVal)

Viewing 3 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply