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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
aflintdepm
Helper III
Helper III

Next Visit Type by Visit Date

I have a table of client visits and visit dates (all future).  There are multiple visit types that could be scheduled, but I would like to report what the next visit type is, not the when.

 

Here is a small sample:

Patient NameVisit TypeVisit Date
John SmithRegular7/25/2024
Betty JonesAnnual8/1/2024
Bob JohnsonRegular7/10/2024
John SmithAnnual8/25/2024
Betty JonesRegular9/1/2024
Bob JohnsonAnnual8/15/2024

 

For this example, I would like the results to look like this:

Patient NameNext Scheduled Visit Type
John SmithRegular
Betty JonesAnnual
Bob JohnsonRegular

 

I know how to calculate when the next visit is, but I don't know how to return the value in Visit Type based on that calculation.

 

Any and all help appreciated.  Thank you

1 ACCEPTED SOLUTION
gmsamborn
Super User
Super User

Hi @aflintdepm 

 

Would a measure like this help?

Next Visit Type = 
VAR _NextDate =
    CALCULATE(
        MIN( 'Table'[Visit Date] ),
        'Table'[Visit Date] > TODAY()
    )
VAR _NextType =
    CALCULATE(
        MAX( 'Table'[Visit Type] ),
        'Table'[Visit Date] = _NextDate
    )
RETURN
	_NextType


Proud to be a Super User!

daxformatter.com makes life EASIER!

View solution in original post

1 REPLY 1
gmsamborn
Super User
Super User

Hi @aflintdepm 

 

Would a measure like this help?

Next Visit Type = 
VAR _NextDate =
    CALCULATE(
        MIN( 'Table'[Visit Date] ),
        'Table'[Visit Date] > TODAY()
    )
VAR _NextType =
    CALCULATE(
        MAX( 'Table'[Visit Type] ),
        'Table'[Visit Date] = _NextDate
    )
RETURN
	_NextType


Proud to be a Super User!

daxformatter.com makes life EASIER!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.