Search code examples
excelsumaveragesumifssubtotal

Calculation subtotal with if function


I have the following formula in a separate table to the below (below table is data set).

However the results for the section are out by one section

e.g. How can I get the licensing result in the cash?

=AVERAGE(IF(Table1[[#All],[SECTION_NAME]]=[@[SECTION_NAME]],IF(SUBTOTAL(102,OFFSET($G$12,ROW(Table1[RC - 1 RESULTS])-ROW(G$12),0)),Table1[RC - 1 RESULTS])))

enter image description here


Solution

  • So in case anyone ever has the same issue, I found my own answer by using the array formula below:

    =AVERAGE(IF(Table1[SECTION_NAME]=@[SECTION_NAME]],IF(SUBTOTAL(102,OFFSET($G$13,ROW(Table1[RC - 1 RESULTS])-ROW(G$13),0,1)),Table1[RC - 1 RESULTS])))
    

    Don't forget to enter it as an array by selecting the formula and holding Ctrl and Shift and pressing Enter.

    Hope this helps someone else :)

    J.