Average IFS in combination with Subtotal

chaz6623

New Member
Joined
Jul 21, 2021
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Good day,

I hope to find some help with a formula that is driving me nuts for over a week.

I have a rather large spreadsheet which I need to use Subtotal/Sumproduct to filter our or return results when I filter monthly. I want to find an average of that Subtotal but filtering 2 different columns.

I'd like to average column G while filtering for columns R & S. This the formula I thought I could use but it is not returning the correct figures.

=AVERAGE(IF(SUBTOTAL(2,OFFSET(A1,ROW(G10:G1501)-ROW(G10),0,1)),IF(R10:R1501=0,G10:G1501),IF(S10:S1501=0,G10:G1501)))

any help?
 

Attachments

  • Capture 1.JPG
    Capture 1.JPG
    92.4 KB · Views: 43

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
It might be that some of the data in column A is not numeric and is ignored by subtotal(2.

See if this one gives the correct result.
Excel Formula:
=AVERAGE(IF(SUBTOTAL(9,OFFSET(G1,ROW(G10:G1501)-ROW(G10),0,1)),IF(R10:R1501=0,G10:G1501),IF(S10:S1501=0,G10:G1501)))

Without knowing the expected result for a data set that is currently returning an incorrect result it is going to be difficult to pinpoint the problem.
 
Upvote 0
=AVERAGE(IF(SUBTOTAL(9,OFFSET(G1,ROW(G10:G1501)-ROW(G10),0,1)),IF(R10:R1501=0,G10:G1501),IF(S10:S1501=0,G10:G1501)))

Thank you for the reply.

In the example sheet I uploaded here, when filtering Row R & S to "0" - the total on Column G is $3179.24. Diving that by 2 (the filtering only brings 2 results) the average is $1589.62
The formula you provided gave a result of $5.16

I had another formula in another cell that gives the correct average amount BUT it is because I manually filtered the R column.

=AVERAGE(IF(SUBTOTAL(2,OFFSET(G10,ROW(G10:G1502)-ROW(G10),0)),IF(R10:R1502=0,G10:G1502)))

Similarly, when filtering row R to "0" and S to "1" - the total on Column G is $14950.43. Diving that by 2 (the filtering only brings those 2 results) the average is $7475.21
The formula brings a result of $3737.61. - Somehow the formula is dividing by 4 not 2 ($14950.43 / 4 = $3737.61)
 
Upvote 0
I thought that there would be more data not visible in the screen capture. I've done a test on the values shown and this formula works correcty.

Excel Formula:
=AVERAGE(IF(SUBTOTAL(9,OFFSET(G10,ROW(G10:G1501)-ROW(G10),0,1)),IF(R10:R1501+S10:S1501=0,G10:G1501)))
 
Upvote 0
I thought that there would be more data not visible in the screen capture. I've done a test on the values shown and this formula works correcty.

Excel Formula:
=AVERAGE(IF(SUBTOTAL(9,OFFSET(G10,ROW(G10:G1501)-ROW(G10),0,1)),IF(R10:R1501+S10:S1501=0,G10:G1501)))

Thanks!!!!!! that does work.

What about when R is "0" but S is "1"?
 
Upvote 0
See if this works,
Excel Formula:
=AVERAGE(IF(SUBTOTAL(9,OFFSET(G10,ROW(G10:G1501)-ROW(G10),0,1)),IF(((R10:R1501=0)+(S10:S1501=1))=2,G10:G1501)))
 
Upvote 0
See if this works,
Excel Formula:
=AVERAGE(IF(SUBTOTAL(9,OFFSET(G10,ROW(G10:G1501)-ROW(G10),0,1)),IF(((R10:R1501=0)+(S10:S1501=1))=2,G10:G1501)))

You sir ARE the MAN!!!!

Thank you so much.
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,937
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top