Forum Discussion
Problems with MTBF calculations
I've been trying to emulate the MTBF calculations in this blog post: https://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586. I'm having problems with the Dax formulas in it. For example, the author shows:
Uptime =
VAR next = MINX(FILTER(Repairs,
Repairs[MachineName]=EARLIER(Repairs[MachineName]) &&
Repairs[RepairStarted]>EARLIER(Repairs[RepairStarted]) &&
Repairs[RepairType]<>"PM"
),Repairs[RepairStarted])
RETURN IF([RepairType]="PM", 0,IF(ISBLANK(next),
DATEDIFF([RepairCompleted],NOW(),SECOND),
DATEDIFF([RepairCompleted],next,SECOND)
)
)
I modified it to my data and get this:
I get this error: The syntax for ',' is incorrect. (DAX(VAR next = MINX(FILTER(Repairs, Repairs[Asset #]=EARLIER(Repairs[Asset #]) && Repairs[DateIn]>EARLIER(Repairs[DateIn]) && Repairs[comments]<>"Return to bin" ),Repairs[DateIn].[Day])RETURN IF(Repairs[comments="Return to bin", 0,IF(ISBLANK(next), DATEDIFF([DateOut],NOW(),DAY), DATEDIFF([DateOut],next,Day) ) ))).
I also get red underlines under all of the columns next to EARLIER and DATEDIFF. Anyone have any ideas?
- Looks like you are missing a comma or semi-colon after the VAR next line.
Yes! I was missing the comma. BTW I just bought your book. Thanks for your help!
9 Replies
- Greg_DecklerCommunity ChampionSounds like you need to change the commas to semi-colons ( ; ). Regional language settings.
- rbartlejrHelper III
Greg_Deckler Ok, I tried that and get this error: EARLIER/EARLIEST refers to an earlier row context which doesn't exist. I looked in the data and there are more than one asset #s in several rows.
- Greg_DecklerCommunity ChampionAnd is this a column you are creating? It should be a column and not a measure if I remember correctly.