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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
MattRo
Frequent Visitor

How to compare dates from two related tables and generate accuracy rate

Hello. I work in a hospital and we want to compare the actual discharge date of a patient with accuracy of our estimate from earlier. I have two tables related (1:many) by a patient ID number (MRN).

 

Table 1 - Yesterdays DCs

  • MRN
  • Disch Date

Table 2 - DC Info - This table give patient information on a daily basis. There are multiple/duplicate MRN in this table and I am interested in Expected Dischrg when Report Date/Time is latest.

  • MRN
  • Expected Dischrg
  • Report Date/Time

Can you help me with a measure that will give the percentage of MRNs that have the correct Expected Dischrg date?

 

Example:

Below, you can see, on 3/24, we discharged 9 patients where we had predicted they would discharge on 3/24. And there where 20 patients discharged where we had the estimate wrong.

MattRo_3-1679967835221.png

Side note - Not to sidetrack, but a second question...I think the column above is misleading or wrong, "Latest Expected Dischrg" is not the same as "last reported" Expected Dischrg which would be more accturate.

 

Thank you!

3 REPLIES 3
amitchandak
Super User
Super User

@MattRo , You need have common MRN dimension, post that you need have measures

 

measure =

var _diff = datediff(max(Table1[DesChg]), max(Table2[Expected DesChg]), day)

return

countx(values(MRN[MRN]), if(_diff  <>0 , [MRN], blank() ) )

 

Now you can divide ot with countrows(filter(Table, Table1[DesChg] <> Blank()))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

@amitchandak 
Using your measure, I managed to come up with this which identifies the matches. I think I am on the right track, but I am not able to sum. Any ideas?

 

MattRo_2-1680050050119.png

 

using this measure:

EDD Accurate? =
var _diff = datediff(max('Yesterday DCs'[Disch Date]), max('DC info'[Expected Dischrg]), day)
return
countx(
    values('Yesterday DCs'[MRN.DCd]),
    if(_diff  <>0 , blank(), 1)
)

@amitchandak  Hi. Thanks for the response! Could you elaborate on "You need to have a common MRN dimension"? Do you mean I need to create a separate table containing MRN only? What would the purpose be given that I already have a table with a column of all unique MRN values? Thank you.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.