I would suggest tackling this in two parts:
- Use the EARLIER function to address the prior row context issue.
http://portal.enterprisedna.co/courses/dax-formula-deep-dives/lectures/6775377
- Wrap a CALCULATE( IF () ) statement around the EARLIER portion of the calculation to do the reset on Metric Name.
If you look at post #7 in this thread, it provides an example of how to do this:
Calculating Difference Between Dates in Same Column with Multiple Events on Same Day - #7 by BrianJ
EARLIER isn’t used much anymore since the introduction of variables to DAX, but this seems like a textbook application of it, particularly for a calculated column.
I hope this is helpful.
- Brian