In the averageif function, you are asking to retrieve the average of numbers in a range (orange shaded column) when the condition (i.e. 40) is satisfied in the test range (blue shaded column). You are getting an error because there is no 40 in the test range. In other words, no averaging will take place because the condition is not satisfied. If you set up this function again and include 40 in the test range, then the condition is satisfied and averaging will take place.
Long story short: You need to add 40 to the blue section or change the function.