Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Get nth value from a dataset

Hi   I am trying to get the value at particular indexes in a dataset. This is as part of calculating the confidence interval for the median. This data will change based on slicers.   We are curre...
  • PaulDBrown's avatar
    PaulDBrown
    4 years ago

    Ok, I see what you mean...

    How about:

    EDIT: Instead of creating the Rank for car in step 1 below, it will probably work using a much simpler:

    1) Index for Rank =SUM(Table[car]) * 10000 + SUM(Table[Index])

    which avoids needing two RANKX- you will need to take into account the number of rows for the *10000 = or make it really huge like * 1000000000

    1) Create a measure combining car rank and index as follows:

     

     

    Index for Rank =
    VAR _t =
        RANKX ( ALLSELECTED ( 'Table' ), [Sum car],, ASC, DENSE )
    VAR _V =
        _t * 1000
            + SUM ( 'Table'[index] )
    RETURN
        _V
    

     

     

    Now the rank measure to use to choose the nth value:

     

     

    Rank = 
    RANKX(ALLSELECTED('Table'), [Index for Rank], ,ASC,Dense)

     

     

     

    New file attached

  • PaulDBrown's avatar
    PaulDBrown
    4 years ago

    Correct!

    but use the method

    Index for Rank =SUM(Table[car]) * 100000000000 + SUM(Table[Index])

    as the first step (to avoid using the costly RANKX), and then use RANKX over this [Index for Rank].

    In theory, using the car value * 10000000000 "provides" the correct order; adding the index makes each value unique.