Forum Discussion

mattramirez2020's avatar
5 years ago
Solved

Most Recently Seen Provider

Hello!

 

I am trying to create a calculated column in a customer table that gives me the most recently seen provider from an appointment table. I have been able to make a column that gives me their most recently completed appointment date but for some reason, I can't make giving the corresponding provider work.

 

Any help would be greatly appreciated!

 

Table: Appointment

CustomerIDApptDateProviderStatus
11/1/2020ABCompleted
16/5/2020BCCompleted
112/12/2020DFNot-Confirmed
24/8/2020ABCompleted
36/12/2020DENo-Show
311/15/2020GHNot-Confirmed

 

Table: Customer

CustomerIDDate of Last Completed VisitLast Visit Provider (what I need!)
16/5/2020BC
24/8/2020AB
3  

 

What I am looking for:

A calculated column for Last Visit Provider that looks at the appointment table and for an appointment with a status of "Completed".

 

Ideally, I think a calculated column would be the best thing but if anyone thinks I should make a measure instead, let me know!

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi mattramirez2020 ,

     

    Check the formulas

    Column = CALCULATE(MAX(Appointment[ApptDate]),FILTER(Appointment,Appointment[CustomerID]=Customer[CustomerID]&&Appointment[Status]="completed"))
    
    Column 2 = CALCULATE(MAX(Appointment[Provider]),FILTER(Appointment,Appointment[CustomerID]=Customer[CustomerID]&&Appointment[ApptDate]=Customer[Column]))

    Result would be shown as below.

     

    Best Regards,

    Jay

     

3 Replies

  • mattramirez2020 , Create a new column in Customer table as

    maxx(filter(Appointment, Appointment[CustomerID] = Customer[CustomerID]),[ApptDate])

    • mattramirez2020's avatar
      mattramirez2020
      Helper II

      amitchandak So I have that formula already for Date of Last Visit! I actually need the corresponding Provider for that date!

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi mattramirez2020 ,

         

        Check the formulas

        Column = CALCULATE(MAX(Appointment[ApptDate]),FILTER(Appointment,Appointment[CustomerID]=Customer[CustomerID]&&Appointment[Status]="completed"))
        
        Column 2 = CALCULATE(MAX(Appointment[Provider]),FILTER(Appointment,Appointment[CustomerID]=Customer[CustomerID]&&Appointment[ApptDate]=Customer[Column]))

        Result would be shown as below.

         

        Best Regards,

        Jay