Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
puru85
Helper II
Helper II

Help Needed: Calculating Wait Time for Outpatients in Power BI

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!


 

 

 

1 ACCEPTED SOLUTION
rajendraongole1
Super User
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!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

1 REPLY 1
rajendraongole1
Super User
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!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors