In a calculated column, is there a way to combine OVER with a custom TERR function?