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
Anonymous
Not applicable

Recent record based on filter - calculated column

Hello all,

 

I'm trying to create a calculated column to display a "True" text for the last agent who handeled a customer ticket.

 

Current table:

Customer IDAgentDate
111A20/02
111B23/04
111C02/05
222Y01/09
222X11/10
222F12/10
333D07/02
333Y03/11

 

Ideal situation:

 

Customer IDAgentDateLast Agent?
111A20/02 
111B23/04 
111C02/05True
222Y01/09 
222X11/10 
222F12/10True
333D07/02 
333Y03/11True

 

I tried several ways but none worked out well. I appricate your help in advance. 

 

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

Hi @Anonymous ,

You can create a calculated column as below:

Last Agent? = 
VAR _maxdate =
    CALCULATE (
        MAX ( 'Table'[Date] ),
        FILTER ( 'Table', 'Table'[Customer ID] = EARLIER ( 'Table'[Customer ID] ) )
    )
RETURN
    IF ( 'Table'[Date] = _maxdate, "True" )

yingyinr_0-1626682009908.png

Best Regards

Community Support Team _ Rena
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

3 REPLIES 3
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

You can create a calculated column as below:

Last Agent? = 
VAR _maxdate =
    CALCULATE (
        MAX ( 'Table'[Date] ),
        FILTER ( 'Table', 'Table'[Customer ID] = EARLIER ( 'Table'[Customer ID] ) )
    )
RETURN
    IF ( 'Table'[Date] = _maxdate, "True" )

yingyinr_0-1626682009908.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

@Anonymous , A new column

if([Date] = maxx(filter(Table, [Customer ID] =max([Customer ID]) ),[Date]) , true(), blank())

 

Anonymous
Not applicable

Thank you for your answer, I've just tried it and it didn't work out. It's showning me that all recrods are false. This DAX doesn't filter based on the agent. 

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.