Forum Discussion

TabathaN's avatar
TabathaN
Advocate III
6 years ago
Solved

Calculate 3rd Opening

Hello,   I work for a medical practice and we are looking to create a table/matrix that shows the 3rd next opening on a providers schedule. I am at a loss on how to accomplish this and could really...
  • v-juanli-msft's avatar
    v-juanli-msft
    6 years ago

    Hi TabathaN 

    Create three measures

    Measure = MAX('Table'[Appointment Date])
    
    3rd Next Avail =
    CALCULATE (
        MAX ( 'Table'[Appointment Date] ),
        TOPN (
            3,
            FILTER (
                ALLSELECTED ( 'Table' ),
                'Table'[Scheduling Provider] = MAX ( 'Table'[Scheduling Provider] )
                    && FIND ( "Open", 'Table'[Appointment Status], 1, 0 ) > 0
            ),
            [Measure], ASC
        )
    )
    
    
    3rd Next New Patient =
    CALCULATE (
        MAX ( 'Table'[Appointment Date] ),
        TOPN (
            3,
            FILTER (
                ALLSELECTED ( 'Table' ),
                'Table'[Scheduling Provider] = MAX ( 'Table'[Scheduling Provider] )
                    && FIND ( "Open", 'Table'[Appointment Status], 1, 0 ) > 0
                    && 'Table'[Appointment Type] = "New Patient"
            ),
            [Measure], ASC
        )
    )
    

    Best Regards
    Maggie
    Community Support Team _ Maggie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.