Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hi, here is the context of my question :
I am working with alerts, status (Turned On or Off ) and timestamps along with other values that are not relevant to what I'm asking here,
So there is a column for the alerts, which can repeat themselves without being the exact same alert but with the same tag, and there is a column for the timestamps and status.
I want to be able to get the previous timestamp of the alerts when they were turned on based on when they appear turned off ( acknowledged by operator ). In that case, the correct timestamp would be the one associated with the last time that the alarm was turned on which could be pretty far in terms of rows.
This is for a measure that would indicate the duration between the unique alert being turned on and turned off.
I should also mention that the status is in TEXT and the alert tag is also in TEXT
Thank you very much!!
Solved! Go to Solution.
Hi @Anonymous ,
I created the data:
Here are the steps you can follow:
1. Create calculated column
group =
RANKX(FILTER('Table','Table'[alerts]=EARLIER('Table'[alerts])),'Table'[timestamps],,ASC)
time =
var _1=CALCULATE(MAX('Table'[timestamps]),FILTER(ALL('Table'),'Table'[group]=EARLIER('Table'[group])-1&&'Table'[alerts]=EARLIER('Table'[alerts])))
return
DATEDIFF(_1,[timestamps],HOUR)
2. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
I created the data:
Here are the steps you can follow:
1. Create calculated column
group =
RANKX(FILTER('Table','Table'[alerts]=EARLIER('Table'[alerts])),'Table'[timestamps],,ASC)
time =
var _1=CALCULATE(MAX('Table'[timestamps]),FILTER(ALL('Table'),'Table'[group]=EARLIER('Table'[group])-1&&'Table'[alerts]=EARLIER('Table'[alerts])))
return
DATEDIFF(_1,[timestamps],HOUR)
2. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous Check if this helps: See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586.
The basic pattern is:
Column =
VAR __Current = [Value]
VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])
VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
__Current - __Previous
If not, sample data would help tremendously. Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882
Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.