Forum Discussion
DateDiff between rows of Status changes
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
Hi Greg_Deckler ,
Thank you for your prompt reply to my inquiry. I've read through your article and think it is a brilliant algorithm for calculating concurrent timestamps for calculating MTBF. I tried adjusting the code to fit my scenario, but unfortunately come across an ERROR when I attempt to create the new column with the VAR Next code. Apologies for my naivete with regard to PwrQuery and DAX.
I get these errors any time I try to use code with a variable declaration in the beginning, is there something I am doing wrong or misunderstanding with regard to DAX functionality.
StsTimeDiff =
VAR next = MINX(FILTER(MASTER3_FIELDHISTORY,
MASTER3_FIELDHISTORY[mrID]=EARLIER(MASTER3_FIELDHISTORY[mrID]) &&
MASTER3_FIELDHISTORY[mrTIMESTAMP]>EARLIER(MASTER3_FIELDHISTORY[mrTIMESTAMP])
),MASTER3_FIELDHISTORY[mrTIMESTAMP])
RETURN IF(ISBLANK(next),
DATEDIFF([mrTIMESTAMP],NOW(),MINUTE),
DATEDIFF([mrTIMESTAMP],next,MINUTE)
)Error: Token Eof expected.
Show error highlights the VAR next segment at the top.
Steps I took, for reference:
- Go to Power Query tab
- Entered Power Query table/query editor
- Select Add Column tab
- Select Custom Column button
- Name the column, "StsTimeDiff"
- Paste code starting at VAR
- Receive the Token Eof Expected error, can't click okay.
Sincerely,
Kristopher