Forum Discussion

Auski's avatar
Auski
Advocate I
2 years ago
Solved

DAX Measure addition/change help needed

Good afternoon all,

 

I have the following measure to return the latest task/appointment date, which works brilliantly. 

 

Appointment (ALL) Most Recent =
VAR appttaskdate =
    CALCULATE (
        MAX ( Task[Created_Date] ),
        FILTER ( Task, Task[Created_Date] < TODAY () ),
        Task[task_record_type] <> "System Generated Task"
    )
VAR apptdate =
    CALCULATE (
        MAX ( Appointments[appointment_date] ),
        FILTER ( Appointments, Appointments[appointment_date] < TODAY () ),
        Appointments[status] = "Completed"
    )
RETURN
    IF ( apptdate > appttaskdate, apptdate, appttaskdate )

 

 

Based of this measure, I now also need to return Task[task_record_type]. Any ideas how I might do this? Would a second measure be best, or modify this measure?

https://drive.google.com/file/d/1poBCfP3UPDIl7tDuTjHdfsBuyqT2cEwA/view?usp=sharing

Thanks so much,

 

 

7 Replies

  • Auski , Try like

     

    CALCULATE (
    Lastnonblankvalue ( Task[Created_Date], max(Task[task_record_type] )),
    FILTER ( Task, Task[Created_Date] < TODAY () ),
    Task[task_record_type] <> "System Generated Task"
    )

  • amitchandak Thanks for your time with this. I think you are close, however I neglected to mention there is Task[task_record_type] and also Appointment[Record Type] to consider.

    Appointment (ALL) Most Recent =
    VAR appttaskdate =
        CALCULATE (
            MAX ( Task[Created_Date] ),
            FILTER ( TaskTask[Created_Date] < TODAY () ),
            Task[task_record_type] <> "System Generated Task"
        )
    VAR apptdate =
        CALCULATE (
            MAX ( Appointments[appointment_date] ),
            FILTER ( AppointmentsAppointments[appointment_date] < TODAY () ),
            Appointments[status] = "Completed"
        )
    RETURN
        IF ( apptdate > appttaskdate, Task[task_record_type], Appointment[Record Type] )



    Hope that makes sense. 

    I have shared on my google drive.
    https://drive.google.com/file/d/1poBCfP3UPDIl7tDuTjHdfsBuyqT2cEwA/view?usp=sharing 

    Thanks!!