Search code examples
excelaveragecriteria

Excel: Returning a specific value if found


I want to be able to calculate the average a student, however, if it finds a specific number between the averaged subjects, then it will return that specific number AND NOT calculate the average. Example:

If Jack has the following averaged grades in some amount of subjects - 2 3 4 5 5 - then I would want Excel to calculate the average. The answer would be 3.8.

However, if Josh has the following averaged grades - 1 2 3 4 5 - then I would want Excel to return 1 has Josh's average because it found a specific given number in his averaged grades, in this example that would be 1. I want it to return 1 as an answer, and not 3.

I don't know if it makes any sense. I tried to make it understandable. I tried mixing up varies functions, but with no results. Do I have to use VBA for that?


Solution

  • Use this formula:

    =IFERROR(INDEX(A:A,MATCH(1,A:A,0)),AVERAGE(A1:A5))
    

    enter image description here

    enter image description here