Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
govi
Helper II
Helper II

Return last occurrence(DateTime) of certain status filtered by UserName

Hi,

Can't figure this out:

 

I have a table(events) with 3 columns:

table.jpg

 

I want to return the DateTime of the last occurrence of the Status "Finished" per UserName.

 

Can anyone help?

 

Thanks!

govi

 

 

 

 

 

 

 

2 ACCEPTED SOLUTIONS
themistoklis
Community Champion
Community Champion

@govi

 

Create a new Calculated column and not Measure and add the following formula:

Rank = 
VAR d = 'Table'[DateTime]  
VAR a = 'Table'[UserName]   
RETURN
    CALCULATE (
        RANK.EQ ( d, 'Table'[DateTime], DESC ),
        FILTER ( ALL ( 'Table' ), 'Table'[UserName]= a && 'Table'[Status]="Finished")
    )

 

Then create a new table object and on filter section put the rank field with value 1

image.png

View solution in original post

AlB
Community Champion
Community Champion

Hi @govi

Try this:

1. Place Events[UserName] in the rows of a matrix visual

2. Place this measure in values of the matrix:

 

LastOccurrence =
CALCULATE ( MAX ( Events[DateTime] ), Events[Status] = "Finished" )

 

 

 

 

View solution in original post

6 REPLIES 6
AlB
Community Champion
Community Champion

Hi @govi

Try this:

1. Place Events[UserName] in the rows of a matrix visual

2. Place this measure in values of the matrix:

 

LastOccurrence =
CALCULATE ( MAX ( Events[DateTime] ), Events[Status] = "Finished" )

 

 

 

 

Thanks @AlB !

Also a very useful solution.

I will use the solution @themistoklis provided for now because it is nice to have the returns in a column

jhd
Helper I
Helper I

Hi @govi

I am trying to figure out something VERY similar...

To use your example, this is as far as I have got:

 

=CALCULATE(

LASTDATE(DateTime),
FILTER(ALLEXCEPT(NameOfYourTable,UserName),Status="Finished"))

However, as you are probably also experiencing, it doesn't work...

 

The ALLEXCEPT UserName appears to be ignored, and the last Finished date is returned regardless of UserName.

 

 

 

themistoklis
Community Champion
Community Champion

@govi

 

Create a new Calculated column and not Measure and add the following formula:

Rank = 
VAR d = 'Table'[DateTime]  
VAR a = 'Table'[UserName]   
RETURN
    CALCULATE (
        RANK.EQ ( d, 'Table'[DateTime], DESC ),
        FILTER ( ALL ( 'Table' ), 'Table'[UserName]= a && 'Table'[Status]="Finished")
    )

 

Then create a new table object and on filter section put the rank field with value 1

image.png

Anonymous
Not applicable

Hello! Hate to gravedig, but I'm getting a weird error with this forumla. It's ranking my entries in proper date order, and skipping *almost all* of my filter, but seems to be pushing the rank to lines with the same date. My running theory is that the formula sees that they're the same date (text) and just borks but I have no idea what I'm doing so who knows!

 

PBIDesktop_RQFZ7CV4Wm.png

Thanks @themistoklis

This is what I am looking for!

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.