Find next or previous

If no next goal or measurement is found, find the previous.