Solution was fairly easy, just grab first and last metric and do the math, no function needed at all.