Forum Discussion

sroper2001's avatar
sroper2001
Copper Contributor
Dec 06, 2022
Solved

AVERAGEIF criterion is itself a conditional

I suspect this has been answered before, though  I searched and couldn't find it.   I want to find the average value of a column of numbers, but ONLY of the number exceeds the value of the cell in an adjacent column.  For example, from the following table...

 

 AB
11.250.38
22.240.43
31.680.57
41.750.48
51.880.62
61.420.32
70.380.51
80.490.61
90.120.18
100.790.30

 

 

...I want to find the average of the values in column A if and only if that value exceeds its adjacent value in column B.    These A values are in bold font above.  The excel function =AVERAGEIF(A1:A10,">"&B1) isn't correct, of course.  But what is the correct criterion for such a case?

  • sroper2001 

    =AVERAGE(IF(A1:A10>B1:B10,A1:A10))

    You can try this formula. Enter the formula with ctrl+shift+enter if you don't work with Office365 or Excel 2021.

     

4 Replies

  • sroper2001 

    Currently, the best formula would be

    = AVERAGE(
        FILTER(A, A>B)
      )

    where A and B are names given to your variables.

    = AVERAGE(
        IF(A>B,A)
      )

    would also work.

    • sroper2001's avatar
      sroper2001
      Copper Contributor
      Yup, also quite good. Introduced me to the FILTER function! Thanks, Peter!!
  • sroper2001 

    =AVERAGE(IF(A1:A10>B1:B10,A1:A10))

    You can try this formula. Enter the formula with ctrl+shift+enter if you don't work with Office365 or Excel 2021.

     

    • sroper2001's avatar
      sroper2001
      Copper Contributor
      Yes! Perfect!! A million thanks! I assume will also work with SUMIF when I want to sum those numbers instead of averaging them. You've made my day!

Resources