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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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