Forum Discussion

MagikJukas's avatar
MagikJukas
Icon for Resolver III rankResolver III
2 years ago
Solved

Sum up hierarchy not working (with sample)

Hello, I would like to sum up measure 2 children into measure 3 parent. Measure 3 should return 1.48, insteaed of 0.83, for the first row.   Below the formulas: Measure 2 = ABS(CALCULATE([FCST ...
  • talespin's avatar
    2 years ago

    hi MagikJukas 

     

    Please see if this is what you want, As the below post said, I wonder why would you do that.

     

    Measure 2 = SWITCH(
                        TRUE(),
                        ISINSCOPE(Forecast[Material]), ABS(([FCST Acc.])-CALCULATE([FCST Acc.],REMOVEFILTERS(Forecast[Series],Forecast[Material])))
                        )
     
    Measure 3 =
    VAR _SelSeries = SELECTEDVALUE(Forecast[Series])
    VAR _FCSTAccTotal = CALCULATE([FCST Acc.],REMOVEFILTERS(Forecast[Series],Forecast[Material]) )
    VAR _Sum = SUMX(VALUES(Forecast[Material]), ABS([FCST Acc.] - _FCSTAccTotal) )

    RETURN SWITCH(
            TRUE(),
            NOT(ISINSCOPE(Forecast[Material])) && ISINSCOPE(Forecast[Series]), _Sum
            )
     

     

  • MagikJukas's avatar
    MagikJukas
    2 years ago

    Hello talespin 

    thanks for your reply.

    Indeed, your solution work with the sample I provided.

     

    However, when testing in the original dataset, it was not working.

    the solution was to change

    REMOVEFILTERS(Forecast[Series],Forecast[Material]

    with 

    REMOVEFILTERS(Forecast[Material]),ALLSELECTED(Forecast))

     

    By doing so, the measure keeps the selected filters expect for the Material, which is what I wanted.

     

    thanks!