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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Anonymous
Not applicable

Earlier Function

PersonPhaseStatusDateTime
PeterSleepingRunning04/03/2019 13:06
PeterSleepingRunning04/03/2019 13:07
PeterSleepingComplete04/03/2019 13:08
JohnEatingRunning05/03/2019 14:06
JohnEatingComplete05/03/2019 14:26
MarcusStudyingRunning07/03/2019 15:16
MarcusEatingRunning07/03/2019 15:45
MarcusStudyingComplete07/03/2019 15:46
MarcusEatingComplete07/03/2019 15:56

 

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

Hi, @Anonymous 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

a1.png

 

You may create a calculated column as below.

End Date = 
CALCULATE(
    MIN('Table'[DateTime]),
    FILTER(
        ALL('Table'),
        'Table'[Person]=EARLIER('Table'[Person])&&
        'Table'[Phase]=EARLIER('Table'[Phase])&&
        'Table'[Status]="Complete"&&
        'Table'[DateTime]>=EARLIER('Table'[DateTime])
    )
)

 

Result:

a2.png

 

Best Regards

Allan

 

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

5 REPLIES 5
theov
Advocate III
Advocate III

Hi there, basically you can use EARLIER here. This function is explained fully in this video with practical examples. Nowadays we use variables vastly to replace EARLIER but learing this function helps deepen your DAX a lot:

https://www.youtube.com/watch?v=q8zsWqcd1vM

v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

a1.png

 

You may create a calculated column as below.

End Date = 
CALCULATE(
    MIN('Table'[DateTime]),
    FILTER(
        ALL('Table'),
        'Table'[Person]=EARLIER('Table'[Person])&&
        'Table'[Phase]=EARLIER('Table'[Phase])&&
        'Table'[Status]="Complete"&&
        'Table'[DateTime]>=EARLIER('Table'[DateTime])
    )
)

 

Result:

a2.png

 

Best Regards

Allan

 

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

harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

Not very clear.

 

YOu can try

 

New Column = CALCULATE(MAX(Table[DateTime] , Filter(Table, Table[Name] =earlier(Table[Name]) && Table[Phase] =earlier(Table[Phase]) && Table [Status]="Complete"))

 

New Column = Calculate (MAX(Table[DateTime]), Table[Status] = "Complete")

 

Else

 

New Column = IF( Table[Status] = "Complete", Table[DateTime] , BLANK())

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

amitchandak
Super User
Super User

@Anonymous , try new column like

 

maxx(filter(Table, [Name] =earlier([Name]) && [Phase] =earlier([Phase]) && [Status]="Complete"),[DateTime])

or

maxx(filter(Table, [Phase] =earlier([Phase]) && [Status]="Complete"),[DateTime])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thank you for the prompt response. I have to make a status bar. That's why I need to know the start time and the end time of a phase. The maxx(filter(Table, [Phase] ?earlier([Phase]) && [Status]"Complete"),[DateTime]) function would solve the problem if that phase only occurred once, but in my case that phase occurs in several days and on some days several times during that day. So the maxx(filter(Table, [Phase] ?earlier([Phase]) && [Status]"Complete"),[DateTime]) function would give me the maximum date of the last time the phase is completed. Any idea for that every time there is that phase me from the date of the next state completed that phase? Thanks for the help.

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

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.