Forum Discussion
Anonymous
7 years agoNot applicable
DATEDIFF Between Two Columns for Same Value
Hi, So I have a huge table with repeating patients for a hospital. I want to know when the DATEDIFF (in days) between the time they got discharged and the time they came back and readmitted. Not ...
Zubair_Muhammad
7 years agoCommunity Champion
Anonymous
Try this as calculated column
Calc Column =
VAR PreviousRow =
TOPN (
1,
FILTER (
Table1,
[Name] = EARLIER ( [Name] )
&& [Discharge Date] < EARLIER ( [Discharge Date] )
),
[Discharge Date], DESC
)
VAR PreviousDischargeDate =
MAXX ( PreviousRow, [Discharge Date] )
RETURN
DATEDIFF ( PreviousDischargeDate, [Admission date], DAY )
- Anonymous7 years agoNot applicable
Zubair_Muhammad it kind of worked..but is it possible to have the first admission date as 0? I am not sure what value it is yielding since it is the first admission date and there are no prior discharge date.
- Zubair_Muhammad7 years agoCommunity Champion
Anonymous
Sorry for late reply. I had to go out
When I use your sample data I get correct results....the first entry shows blank
See the pic below
- Anonymous7 years agoNot applicable
Zubair_Muhammad Not exactly sure why I have values. I will try to figure it out. Thanks for your help!