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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
bigrods
Helper II
Helper II

Identify no's by value on subsequent row

Hi,

Not sure how to describe this accurately:

 

I have a table of Patient appointments; I'd like to identify the no. of patients where:

 

They have an appointment of Rota Type = "Telemedicine" AND their next appointment by Appointment Date (of any Rota Type) has Follow Up = TRUE

In the example below, I'd expect the value of 1 to be returned, as Patient ID 123456 has a Telemedicine appt on the 10th, then the next appointment they have on 12th is Follow Up = TRUE - even though the Rota Type is different.

 

If the Follow Up is FALSE for the subsequent appointment, I do not want to include this.

Also, the Follow Up value for the Telemedicine appointment could be either TRUE or FALSE; I am not interested in that.

 

Patient IDAppt DateRota TypeFollow Up
12345610-Mar-2022TelemedicineFALSE
98765410-Mar-2022FittingTRUE
12345612-Mar-2022BBV ClinicTRUE
98765414-Mar-2022FittingTRUE

 

Many thanks for any help anyone could give!

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@bigrods,

 

Try this measure:

 

Number of Patients = 
SUMX (
    VALUES ( PatientAppointment[Patient ID] ),
    VAR vPatientID = PatientAppointment[Patient ID]
    VAR vApptDate =
        MINX (
            FILTER (
                ALLSELECTED ( PatientAppointment ),
                PatientAppointment[Patient ID] = vPatientID
                    && PatientAppointment[Rota Type] = "Telemedicine"
            ),
            PatientAppointment[Appt Date]
        )
    VAR vNextApptDate =
        MINX (
            FILTER (
                ALLSELECTED ( PatientAppointment ),
                PatientAppointment[Patient ID] = vPatientID
                    && PatientAppointment[Appt Date] > vApptDate
                    && NOT ISBLANK ( vApptDate )
            ),
            PatientAppointment[Appt Date]
        )
    RETURN
        IF (
            COUNTROWS (
                FILTER (
                    ALLSELECTED ( PatientAppointment ),
                    PatientAppointment[Patient ID] = vPatientID
                        && PatientAppointment[Appt Date] = vNextApptDate
                        && PatientAppointment[Follow Up] = TRUE
                )
            ),
            1
        )
)

 

DataInsights_0-1649358553699.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
DataInsights
Super User
Super User

@bigrods,

 

Try this measure:

 

Number of Patients = 
SUMX (
    VALUES ( PatientAppointment[Patient ID] ),
    VAR vPatientID = PatientAppointment[Patient ID]
    VAR vApptDate =
        MINX (
            FILTER (
                ALLSELECTED ( PatientAppointment ),
                PatientAppointment[Patient ID] = vPatientID
                    && PatientAppointment[Rota Type] = "Telemedicine"
            ),
            PatientAppointment[Appt Date]
        )
    VAR vNextApptDate =
        MINX (
            FILTER (
                ALLSELECTED ( PatientAppointment ),
                PatientAppointment[Patient ID] = vPatientID
                    && PatientAppointment[Appt Date] > vApptDate
                    && NOT ISBLANK ( vApptDate )
            ),
            PatientAppointment[Appt Date]
        )
    RETURN
        IF (
            COUNTROWS (
                FILTER (
                    ALLSELECTED ( PatientAppointment ),
                    PatientAppointment[Patient ID] = vPatientID
                        && PatientAppointment[Appt Date] = vNextApptDate
                        && PatientAppointment[Follow Up] = TRUE
                )
            ),
            1
        )
)

 

DataInsights_0-1649358553699.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @DataInsights - sorry ofr the late reply, thanks so much this has worked! I needed to do a bit of transformations as some of my rota names were "Telemmed", "Tele Meds" "Telemedicine" - I initially tried a Containsstring in my filter and the query ground to a halt! 

But I added a conditional column and all is good - thanks again

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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