Please find attached. I've included an extra table that uses the years as a dimension instead of using all hard-coded dimensions. That might be better than using multiple if statements, which may become cumbersome over time.

Also, instead of using a calculated dimension for the values, I used an expression instead under its corresponding column.

Here, I had to add one small table to your script. But instead of using calculated dimensions, I flipped it and turned the expressions into a dimensions. This allowed me to create those arrows in your chart as you desired. Please find attached.