Forum Discussion

SLima's avatar
SLima
Icon for Helper I rankHelper I
4 years ago
Solved

Previous line

Get previous value.

 

 

 

  • Hi SLima 

     

    Try this code to add a new column:

    Calculada = 
    VAR _A =
        CALCULATE (
            MAX ( 'Table'[Coluna 1] ),
            FILTER ( ALL ( 'Table' ), 'Table'[Coluna 1] < EARLIER ( 'Table'[Coluna 1] ) )
        )
    RETURN
        CALCULATE (
            MAX ( 'Table'[Coluna 2] ),
            FILTER ( ALL ( 'Table' ), 'Table'[Coluna 1] = _A )
        )

     

    output:

     

     

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

    Appreciate your Kudos!!

     

2 Replies

  • Hi SLima 

     

    Try this code to add a new column:

    Calculada = 
    VAR _A =
        CALCULATE (
            MAX ( 'Table'[Coluna 1] ),
            FILTER ( ALL ( 'Table' ), 'Table'[Coluna 1] < EARLIER ( 'Table'[Coluna 1] ) )
        )
    RETURN
        CALCULATE (
            MAX ( 'Table'[Coluna 2] ),
            FILTER ( ALL ( 'Table' ), 'Table'[Coluna 1] = _A )
        )

     

    output:

     

     

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

    Appreciate your Kudos!!

     

  • smpa01's avatar
    smpa01
    Icon for Community Champion rankCommunity Champion

    SLima  you would need a row identifier in the dataset

    Column =
    VAR _0 =
        CALCULATE ( MAX ( 'Table'[RowIdentifier] ) )
    VAR _1 =
        CALCULATE (
            MAX ( 'Table'[Column2] ),
            FILTER ( ALL ( 'Table' ), 'Table'[RowIdentifier] = _0 - 1 )
        )
    RETURN
        _1