I have assumed your data starts in row 2 allowing for a header.

This is the formula for cell K2 ... and then copy down.

Regards