Forum Discussion

rbreneman's avatar
rbreneman
Helper II
5 years ago
Solved

Lookup previous date within table

Hi,   Thanks again AlB for getting me this far. Just when I think I'm getting the hang of DAX I run up against a brick wall and can't see the path forward! I'm struggling to find the right words to...
  • AlB's avatar
    5 years ago

    Hi rbreneman 

    If the bed ID is the column you want to identify the bed, then this will give you the previous end date:

    =
    CALCULATE (
        MAX ( Table1[EndDate] ),
        Table1[StartDate] < EARLIER ( Table1[StartDate] ),
        ALLEXCEPT ( Table1, Table1[BedID] )
    )
    

     you can then use that in your datediff. Probably best would be to assign the value above to a VAR. You should also check for blanks, which will come up in cases as the last row, before applying the datediff

    Please mark the question solved when done and consider giving kudos if posts are helpful.

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

    Cheers