Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Top N nested

Hello everyone,   I am strugling to make a nested Top N.   The data I am currently working with is in a graph which looks like:   Product                             Divison                    ...
  • v-alq-msft's avatar
    6 years ago

    Hi, Anonymous 

     

    Based on your description, there are three ways o achieve your requirement.

     

    Way1:

    You may create a calculated column as follows.

     

     

    RankColumn = 
    COUNTROWS(
             FILTER(
                 'Table',
                 'Table'[Division] = EARLIER('Table'[Division])&&
                 'Table'[SOH] > EARLIER('Table'[SOH])
             )
    )+1

     

     

     

    Result:

     

    Way2:

    You may create a measure as below.

     

     

    RankMeasure = 
    RANKX(
        ALLSELECTED('Table'[Product]),
        CALCULATE(SUM('Table'[SOH])),
        ,
        DESC,
        Dense
    )

     

     

     

    Result:

     

    Way3:

    You may create a calculated table as follows.

     

     

    Table 3 = 
    SUMMARIZE(
        'Table',
        'Table'[Product],
        'Table'[Division],
        'Table'[SOH],
        "rank",
        var _currentdivision = MAX('Table'[Division])
        var _currentsoh = MAX('Table'[SOH])
        return 
        COUNTROWS(
                 FILTER(
                     ALL('Table'),
                     'Table'[Division] = _currentdivision&&
                     'Table'[SOH] > _currentsoh
                 )
        )+1
    )

     

     

     

    Result:

     

    Best Regards

    Allan

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.