Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi Experts,
I'm working on calculating the wait time for outpatients in Power BI.
My dataset includes two tables:
1) Appointment: Contains details about scheduled appointments, including the appointment time.
2) OutpatientVisit: Captures information on outpatient visits, including timestamps for 'Checked In' and 'Consult Start' statuses.
Requirement:
I need to calculate the wait time for outpatients based on the following logic:
Wait Time =
IF (
OutpatientVisit.VisitTime (VisitStatus = 'Checked In') < Appointment.AppointmentTime,
OutpatientVisit.VisitTime (VisitStatus = 'Consult Start') - Appointment.AppointmentTime,
OutpatientVisit.VisitTime (VisitStatus = 'Consult Start') - OutpatientVisit.VisitTime (VisitStatus = 'Checked In')
)
Can anyone advise on the best way to achieve this calculation in Power BI using using DAX. I am fine with either calulated column or Measure.
Attached is the dataset and PBIX.
WaitingTime.xlsx
Waittime.pbix
Thank you!
Solved! Go to Solution.
Hi @puru85 - you can achieve this with a similar logic using a measures.
Adjust the DATEDIFF function to use MINUTE, SECOND, or another unit of time as needed.
for waittime measure:
WaitTimeMeasure =
VAR AppointmentTime =
MAXX (
RELATEDTABLE(Appointment),
Appointment[AppointmentTime]
)
VAR CheckedInTime =
CALCULATE (
MAX (OutpatientVisit[VisitTime]),
OutpatientVisit[VisitStatus] = "Checked In"
)
VAR ConsultStartTime =
CALCULATE (
MAX (OutpatientVisit[VisitTime]),
OutpatientVisit[VisitStatus] = "Consult Start"
)
RETURN
IF (
CheckedInTime < AppointmentTime,
DATEDIFF(AppointmentTime, ConsultStartTime, MINUTE),
DATEDIFF(CheckedInTime, ConsultStartTime, MINUTE)
)
Hope it should works in calculate the wait time for outpatients.
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Proud to be a Super User! | |
Hi @puru85 - you can achieve this with a similar logic using a measures.
Adjust the DATEDIFF function to use MINUTE, SECOND, or another unit of time as needed.
for waittime measure:
WaitTimeMeasure =
VAR AppointmentTime =
MAXX (
RELATEDTABLE(Appointment),
Appointment[AppointmentTime]
)
VAR CheckedInTime =
CALCULATE (
MAX (OutpatientVisit[VisitTime]),
OutpatientVisit[VisitStatus] = "Checked In"
)
VAR ConsultStartTime =
CALCULATE (
MAX (OutpatientVisit[VisitTime]),
OutpatientVisit[VisitStatus] = "Consult Start"
)
RETURN
IF (
CheckedInTime < AppointmentTime,
DATEDIFF(AppointmentTime, ConsultStartTime, MINUTE),
DATEDIFF(CheckedInTime, ConsultStartTime, MINUTE)
)
Hope it should works in calculate the wait time for outpatients.
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Proud to be a Super User! | |
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!