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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.