Forum Discussion

tlong's avatar
tlong
Regular Visitor
6 years ago
Solved

Find previous date for given value

Hi,   I'm trying to create a calculated column that will show the latest previous date for an associated value.  In the example below, I have the "Date" and "Value" columns, and I'm trying to gener...
  • TomMartens's avatar
    6 years ago

    Hey tlong 

     

    use this DAX statement to create a calculated column:

    Column = 
    var _group = 'Table'[Value]
    var _date = 'Table'[Date]
    return
    CALCULATE(
        MAX('Table'[Date])
        , FILTER(
            ALL('Table')  
            , 'Table'[Date] < _date && 'Table'[Value] = _group
        )
    )

    The result will look like this:

    Please be aware that depending of number of rows in your dataset can become incredibly slow, this is simply because the formula and storage engine do not support windowing operations like this.

     

    Hopefully this is what you are looking for.

     

    Regards,

    Tom