Dax help: Shadow context with allselected()

  • I really need your help.  All of my numbers are wrong in production.

    I need to create a ratio whose denominator is dynamic and is determined according to the report filter.

    I created this measure using the allselected function.

    But I have incomprehensible results when I create other measures from this first measure.

    I read an article by Marco Russo which talked about shadow context.

    I would like to know if you have any trick to override the ALLSELECTED () function?

  • 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 4 posts - 1 through 3 (of 3 total)

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