Forum Discussion

mihaita_baro's avatar
mihaita_baro
Icon for Helper II rankHelper II
4 years ago
Solved

First occurence based on two filters

Hi there

 

I have a table where i store multiple appoiments for the same clients. 

 

I need to calculate something called KPI4, which means the first appoiment where AppType is 2,3 or 5 and Attendance is 5 or 6.

 

Below in green is my table and i want the output as KPI_4 in red.

 

Doesnt necesarily have to be a calculated column, can be a measure as well.

 

I've been trying all day and i can't figure out how to use Min(Appoiment) with AppType and Attendance.

 

IDAPPOINTMENTAPPTYPEATTENDANCEKPI_4
85949610/07/201723 
85949614/07/2017261
85949617/07/201723 
88847020/07/201735 
88847010/07/2017251
89149105/07/2017251
89166704/08/201735 
89166705/07/2017261
89166703/07/201732 
89166706/07/201725 
90175912/07/201735 
90175918/07/201726 
90175903/07/2017551
90787603/08/201725 
90787606/07/2017351
  • v-janeyg-msft's avatar
    v-janeyg-msft
    4 years ago

    Hello mihaita_baro 

     

    You can create a column like this:

    KPI_5 = 
    VAR a =
        IF (
            COUNTX ( FILTER ( ALL ( 'Table' ), [ID] = EARLIER ( 'Table'[ID] ) ), [ID] ) >= 2,
            1
        )
    RETURN
        IF (
            a = 1
                && [APPTYPE]
                    IN { 2, 3, 5 }
                        && [ATTENDANCE] IN { 5, 6, BLANK () },
            1
        )

    Did I answer your question ? Please mark my reply as solution. Thank you very much.
    If not, please feel free to ask me.

     

    Best Regards,
    Community Support Team _ Janey

     

7 Replies