Forum Discussion

CatManKuhn's avatar
CatManKuhn
Icon for Helper II rankHelper II
5 years ago
Solved

Dynamic Percentile and Sum Above 80th Percentile

Hi all,    I have a doozy of a question. I am working on calculating a sum of all workers who are above the 80th percentile of tenure. I have a measure created that identifies the 80th percentile a...
  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    5 years ago

    Hi, CatManKuhn ;

    Please try it.

    flag = 
    var _a=CALCULATE(PERCENTILE.INC([Tenure],0.8),ALLEXCEPT(Terminations,Terminations[Office Name]))
    VAR _b =
        CALCULATE (
            PERCENTILE.INC ( Terminations[Tenure], .80 ),
            ALLEXCEPT ( Terminations, 'Terminations'[depart] ))
    VAR _c =
        CALCULATE (
            PERCENTILE.INC ( Terminations[Tenure], .80 ),
            ALLEXCEPT ( Terminations, Terminations[depart2] ))
    
    VAR Cutoff = [80th Percentile]
    var _80= CALCULATE ( COUNTROWS ( Terminations ), Terminations[Tenure] >= Cutoff )
    
    RETURN
      IF(ISINSCOPE(Terminations[depart]),IF(_a<=_b,_80),
      IF(ISINSCOPE(Terminations[depart2]),IF(_b<=_c,_80),_80))

    The final output is shown below:

    Best Regards,
    Community Support Team_ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.