Forum Discussion

murillocosta's avatar
murillocosta
Icon for Helper I rankHelper I
3 years ago

DAX Context

Hi community

 

I am tring to understand what is the context of the situation below.

 

I have the following situation

 

In a very simple words what I basically need is to calculate forecast measure which is:

 

FORECAST = PREVIOUS ACTUAL - INBOUND + OUTBOUND

 

I created the measure below which uses SUMX to perform the formula above.

 

 

The problem is that the [Outbound Final] and is not returning the actual Outbound Final value.

 

For example

 

If I use the same formula but removing [Outbound Final] its working perfectly as I am expecting.

 

 

As the measure  [Outbound Final] is also a calculated measure I think I am missing something in terms of context.

 

I am attaching the file on the link below

 

https://easyupload.io/sjvj1z

 

Thanks

 

 

 

 

2 Replies

  • wdx223_Daniel's avatar
    wdx223_Daniel
    Icon for Community Champion rankCommunity Champion

    too many nest-measure to deconstruct, this leas to maintenance headaches later.

    you can try this code, which can get the result as you demonstrated

     

    Forecast2 = IF(ISBLANK('mMeasures'[Pallets Hired])&&'mMeasures'[Total Inbound]+'mMeasures'[Total Outbound]<>0,LASTNONBLANKVALUE(ALLSELECTED('SUMMARIZE'[Week]),'mMeasures'[Pallets Hired])+SUMX(FILTER(ALLSELECTED('SUMMARIZE'),'SUMMARIZE'[Week]<=MAX('SUMMARIZE'[Week])&&ISBLANK('mMeasures'[Pallets Hired])),'SUMMARIZE'[Total Inbound]-'SUMMARIZE'[Total Outbound]),'mMeasures'[Pallets Hired])
    • murillocosta's avatar
      murillocosta
      Icon for Helper I rankHelper I

      Thanks for that Daniel

       

      It's calculting correctly the two lines 😞

       

      I need the measure [Outbound Final] to be used, in your measure you are using [Total Outbound]. 

       

      My question is exatcly how to perform  this calculation using the Outbound final.

       

      Would be able to help me?

       

       

       

      Thanks