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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
brcrawford
New Member

Looking at 2 Date Columns and Using Earliest Time

I am looking for help with a formula that will look at two date/time columns and use the earlier time.

For example, when calculating the length of stay, it is currently only using the registration date/time (because ideally this is earlier than triage date/time, but not always the case) and caluculating with the discharge date/time to produce the length of stay.

I now want the formula to consider the Triage Date/Time and the Registration Date/Time and decipher which date/time is earlier and use that to then calculate the length of stay of the patient. Is this possible? 

Here is a screenshot of some sample data: 

EDLOS.PNG

 

Thanks in advance! 

 

2 REPLIES 2
ryan_mayu
Super User
Super User

could you pls provide some sample data (not the screenshot)? and what's the expected output based on the sample data you provided?





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

Proud to be a Super User!




rsbin
Super User
Super User

@brcrawford ,

This SWITCH Statement should get you there:
LengthofStay = SWITCH(

                               TRUE(),
                             [Registration Date/Time] < [Triage Date/Time],  [Discharge Date/Time] - [Registration Date/Time],
                             [Discharge Date/Time] - [Triage Date/Time] ).

 

Basically an If statement to determine which is earlier.

Hope this helps.

Regards,

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.