Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

DAX - Return Immediate Previous row value based on existing Rank

Hello there, 

 

I need a calculated column "Result" to be filled up with the immediate previous row value as shown below.

 

Any suggestions please? PS: Do not want this to be a measure value, so may be this could be returned as a table output which can act like a temporary table. There are additional calculations lined up on top of this output.

 

IDDateRankResult ( Immediate Previous Date based on Rank for each ID)
101/01/20212 
102/01/2021101/01/2021
201/01/20213 
203/01/2021201/01/2021
205/01/2021103/01/2021

 

Thanks,

Pravallika

  • Anonymous 

    Add the following calculated column to your table:

    Result = 
    var __currentrank = Table11[Rank]
    var __currentid = Table11[ID]
    var result  = 
        MAXX(
            FILTER( Table11 , Table11[ID] = __currentid && Table11[Rank] = __currentrank + 1 ),
            Table11[Date]
        )
    return
        result

     

     

1 Reply

  • Anonymous 

    Add the following calculated column to your table:

    Result = 
    var __currentrank = Table11[Rank]
    var __currentid = Table11[ID]
    var result  = 
        MAXX(
            FILTER( Table11 , Table11[ID] = __currentid && Table11[Rank] = __currentrank + 1 ),
            Table11[Date]
        )
    return
        result