Does this do what you're looking for?
df$Percentage <-
rowSums(df[as.character(yrs)]) /
rowSums(
outer(df$CofQYr, yrs, FUN = function(x, y) y <= (yrs[length(yrs)]-as.integer(x))) *
as.matrix(df[as.character(yrs)])[match(df$TRADE, ifelse(df$CofQYr=="Total", df$TRADE, NA)),]
)