Forum Discussion

mblydt-hansen's avatar
mblydt-hansen
Frequent Visitor
8 years ago
Solved

Date difference between values in same column

Hi everyone!   I'm still learning DAX and I was wondering if the collective minds of this forum could help me out with coding a custom column that I've been having difficulty with. I feel like my i...
  • Zubair_Muhammad's avatar
    8 years ago

    mblydt-hansen

     

    You could use this calculated column

     

    Column =
    VAR temp =
        TOPN (
            1,
            FILTER (
                Table1,
                Table1[Patient ID] = EARLIER ( Table1[Patient ID] )
                    && Table1[Date of Visit] < EARLIER ( Table1[Date of Visit] )
            ),
            [Date of Visit], DESC
        )
    RETURN
        DATEDIFF ( MINX ( temp, [Date of Visit] ), Table1[Date of Visit], DAY )