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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
jonnyA
Responsive Resident
Responsive Resident

Formula for pulling most recent patient visit

Hello!

Looking for help to create a formula that will bring back the most recent patient visit.  For example, I have an excel file with 20,000 patient names, many of the patients are listed multiple times because they had multiple visits.  How would I create a formula that will only bring back the most recent visit?  Below are the fields I am using.  Thank you in advance!

jonnyA_0-1617062750491.png

 

 

1 ACCEPTED SOLUTION
jonnyA
Responsive Resident
Responsive Resident

Thanks to everyone who responded!

I figured out the answer ...

Max Date = (MAX('ApptDetail'[Appt DateTime]))

View solution in original post

3 REPLIES 3
jonnyA
Responsive Resident
Responsive Resident

Thanks to everyone who responded!

I figured out the answer ...

Max Date = (MAX('ApptDetail'[Appt DateTime]))
BI_Jo
Resolver III
Resolver III

Hi 

 

I would create a latest visit column using the following DAX and use the column as a filter on your report:

LatestVisitColumn =
if('TableName'[Appt DateTime] = CALCULATE(MAX('TableName'[Appt DateTime]),
ALLEXCEPT('TableName','TableName'[Patient ID Field])), "Yes", "No")

The column will say "Yes" if it is the patients latest visit. 
 
Hope that helps
Jo
amitchandak
Super User
Super User

@jonnyA , Create a measure like this and try

 

Measure =
VAR __id = MAX ('Table'[Patient Last Name, First Name] )
VAR __date = CALCULATE ( MAX('Table'[App Date Time] ), ALLSELECTED ('Table' ), 'Table'[Patient Last Name, First Name] = __id )
CALCULATE ( MAx ('Table'[App Date Time] ), VALUES ('Table'[Patient Last Name, First Name] ),'Table'[Patient Last Name, First Name] = __id,'Table'[App Date Time] = __date )

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.