I’ve been able to do dates between to calculate the average time between appointments but now need to figure out the ‘average’ start to end of the length of a clients stay within the clinic.
I’m sure there’s a post out there somewhere that answers this but I’ve read & watched videos nonstop for 2 days and have yet to figure out how to get the average of a datediff calculation w/o adding a custom column.
Unfortunately the raw data of discharge populates when paperwork is completed vs last visit day thus am forced to compare discharge data to full appointment data.
There is no direct link to show which appointments in the appt table are discharged which is why there’s a created dischargeid in both tables.
I’ve got the datediff element working (on the real pbix vs this sample post) but for the life of me I can’t figure out how to get to the average ‘length’ of stay - aka average of the datediff.
I"m wondering how your going to calculate the length of time a client stays within the clinic when you don’t have a start time and end time (in minutes or hours)
Length stay for this purpose is defined as total number of days from initial appointment until discharged as ‘treatment’ has been completed (or insurance ran out or for whatever reason client stopped attending physical therapy appointments. Thus minutes, hours aren’t a needed element. Only how many visits were involved which a visit = unique day as one can’t receive treatment on same case multiple times in one day.
That help?
Hi @gkavesh. To get a non-zero result in your [Average …] measure, make your virtual table reflect the physical table on display (i.e., use the [Discharge] table as the source), then use the ALL function to remove the row context, perhaps something like
This calculation gives an average for each discharge reason, but I’m guessing this is not what you’re looking for. An Excel mockup of the desired outcome would be a good idea if further pursuit is needed.
Which I managed to get the 72.70 by adding a calculated column of the discharge difference to the discharge table and then applied an averagex to that column.
BUT I realize adding custom columns is not the best methodology so thinking the virtual table path would be better - I’ll try your idea to see how it lines up.
Thank you -
The reason for the difference is that I’m using the ‘real’ data while the data I used for this question was a small selection of the data that was changed due to it’s confidential nature.
This solution works and avoids the column add in the actual data.
This one measure solution might also help you further:
(Building further on Greg’s solution, and using the EDNA video about correcting erroneous totals) eDNA DS - Average Between Dates.pbix (169.5 KB)
Avg. Discharge Duration v3 =
AVERAGEX(
SUMMARIZE( Discharge, Discharge[DischargeId], // from table Dischange
“First Visit”, [First Appt Date], // from table AllApts
“Last appoint”, [Last Appt Date]), // from table AllApts
DATEDIFF( [First Appt Date], [Last Appt Date], DAY)) // this calculates the correct total average