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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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