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
jcawley
Helper III
Helper III

Related MAX

Hello all,

 

I am looking to see the last provider a customer has seen in a calculated column.

 

Specifically, what provider was last seen by a customer with a completed appointment. I have two tables. A customer table, that has unique customer IDs, and an appointments table which has a listing of all appointments and their assosciated details.

 Customer Table

Customer IDLast Provider seen?
111 
111 
111 
222 
222 
333 


Appointment Table

Customer IDProviderAppointment DateStatus
111J. Doe9/5/2020Completed
111J. Doe10/5/2020Completed
111A. Doe11/5/2020Completed
222B. Doe8/5/2020Completed
222J. Doe7/5/2020Not Confirmed
333C. Doe11/5/2020Completed


So far I have been trying to use LOOKUPVALUE, but to no avail. It seems to be pulling data, just not specific to Customer ID.

Last Provider Seen =
LOOKUPVALUE(
Appointments[Provider],
Appointments[Appt Date Time],maxx(filter(Appointments, Appointments[Status]="Completed"),Appointments[Appt Date Time])
)

Here is what the desired output would be in the Customer table:

Customer IDLast Provider seen?
111A. Doe
222B. Doe
333C. Doe

Any help would be greatly appreciated!

 

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @jcawley 

I build a sample like yours to have a test.

My Customer Table is a calculated table and I think you may build a relationship between Customer ID columns in two tables.

Customer = VALUES(Appointment[Customer ID])

Then I add a calculated column in Customer Table.

Last Provider Seen = 
VAR _LastDate =
    MAXX (
        FILTER (
            Appointment,
            Appointment[Status] = "Completed"
                && Appointment[Customer ID] = EARLIER ( Customer[Customer ID] )
        ),
        Appointment[Appointment Date]
    )
RETURN
    CALCULATE (
        MAX ( Appointment[Provider] ),
        FILTER (
            Appointment,
            Appointment[Customer ID] = EARLIER ( Customer[Customer ID] )
                && Appointment[Status] = "Completed"
                && Appointment[Appointment Date] = _LastDate
        )
    )

Result is as below.

1.png

You can download the pbix file from this link: Related MAX

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

View solution in original post

6 REPLIES 6
v-rzhou-msft
Community Support
Community Support

Hi @jcawley 

I build a sample like yours to have a test.

My Customer Table is a calculated table and I think you may build a relationship between Customer ID columns in two tables.

Customer = VALUES(Appointment[Customer ID])

Then I add a calculated column in Customer Table.

Last Provider Seen = 
VAR _LastDate =
    MAXX (
        FILTER (
            Appointment,
            Appointment[Status] = "Completed"
                && Appointment[Customer ID] = EARLIER ( Customer[Customer ID] )
        ),
        Appointment[Appointment Date]
    )
RETURN
    CALCULATE (
        MAX ( Appointment[Provider] ),
        FILTER (
            Appointment,
            Appointment[Customer ID] = EARLIER ( Customer[Customer ID] )
                && Appointment[Status] = "Completed"
                && Appointment[Appointment Date] = _LastDate
        )
    )

Result is as below.

1.png

You can download the pbix file from this link: Related MAX

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

Thank you, RicoZhou! That is the ticket!

Much appreciated.

amitchandak
Super User
Super User

Try a new column in customer table like

maxx(filter(Appointments, Appointments[Status]="Completed" && Appointments[Customer ID] = Customer[Customer ID]), lastnonblankvalue(Appointments[Appt Date Time], Appointments[Provider]))

Hmm, not quite there! It's certainly doing something, but its not always pulling the max date provider.

AilleryO
Memorable Member
Memorable Member

Hi,

 

Did you make a link between your table ?

https://docs.microsoft.com/en-US/power-bi/transform-model/desktop-create-and-manage-relationships

Have you been trying a RELATED()?

Hello AilleryO,

I did, I'm just not sure how to plug RELATED into what I am looking for. I've only used it for simple things so far. 

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.