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

Status of most recent task

I have a table of appointments that fall into 2 categories- Confirmed or Unconfirmed.  For each Unconfirmed, there is a reason.  I need to return the reason based on only the most recent unconfirmed appointment.  I can calculate when the most recent unconfirmed appointment was, but I can't figure out how to return the reason.

 

Data

Appointment DateStatusReason 
5/1/24Confirmed  
6/1/24UnconfirmedCancelled 
7/1/24UnconfirmedNo Show 

 

My formula for most recent unconfirmed date would be:
Most Recent = CALCULATE(MAX('Table'[Appointment Date]), 'Table'[Status]="Unconfirmed", 'Table'[Appointment Date]<=TODAY()

Using the data sample above, I would get 7/1/24 as my result.  Now, how do I get "No Show"?

 

Thank you in advance for any help

1 ACCEPTED SOLUTION
Irwan
Super User
Super User

hello @aflintdepm 

 

your DAX looks good. If you want to get 'Reason' value, just use your DAX but change value inside MAX from date into reason.

Most Recent Reason = CALCULATE(MAX('Table'[Reason]), 'Table'[Status]="Unconfirmed", 'Table'[Appointment Date]<=TODAY())

Irwan_0-1721784134804.png

 

Hope this will help you.

Thank you.

 

 

View solution in original post

3 REPLIES 3
FreemanZ
Super User
Super User

or try to plot a table visual with date column, status column and a measure like:

Measure = 
VAR _currentdate = MAX(data[date])
VAR _statuspre =
    MAXX(
        TOPN(
            1,
            FILTER(ALL(data), data[date]<_currentdate),
            data[date]
        ),
        data[status]
    )
VAR _result = 
    SWITCH(
        _statuspre,
        "Confirmed", "Cancelled",
        "Unconfirmed", "No Show", 
        ""
    )
RETURN _result

 

it worked like:

FreemanZ_1-1721790116083.png

 

FreemanZ
Super User
Super User

Hi @aflintdepm ,

 

not sure if i fully get you, try to add a calculated column like:

column = 
VAR _currentdate = [date]
VAR _statuspre =
    MAXX(
        TOPN(
            1,
            FILTER(data, data[date]<_currentdate),
            data[date]
        ),
        data[status]
    )
VAR _result = 
    SWITCH(
        _statuspre,
        "Confirmed", "Cancelled",
        "Unconfirmed", "No Show", 
        BLANK()
    )
RETURN _result

 

it works like:

FreemanZ_0-1721788986669.png

 

Irwan
Super User
Super User

hello @aflintdepm 

 

your DAX looks good. If you want to get 'Reason' value, just use your DAX but change value inside MAX from date into reason.

Most Recent Reason = CALCULATE(MAX('Table'[Reason]), 'Table'[Status]="Unconfirmed", 'Table'[Appointment Date]<=TODAY())

Irwan_0-1721784134804.png

 

Hope this will help you.

Thank you.

 

 

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.