SubTotal & SubProduct with Filter problem?

ScorpioCRO

New Member
Joined
Aug 2, 2015
Messages
5
Hello,

Well i got one problem. I am trying to calculate some average times with conditions.
TL;DR version ..

In "L" row is my condition that i want to check and in "M" row is the time that i need to get AVERAGE.

So to check with filter results i am using formula:
=SUBTOTAL(101;M7:M22800)

But since I am "lazy" i would like to get all 3 results once i selected date in filter. So to get count i use formula:
=SUMPRODUCT((L7:L22800="Car")*(SUBTOTAL(3;OFFSET(L7;ROW(L7:L22800)-MIN(ROW(L7:L22800));0))))

But now i want to get average time that (example from above) car is used. I use formula:
=SUMPRODUCT(SUBTOTAL(101;OFFSET(M7:M22800;ROW(M7:M22800)-ROW(M7:M22800);;));--(L7:L22800="Car"))

I think formula is giving me AVG for entire sheet, not only for filter results (tbo i cant figure out what number do i get)

So any help about it? I tried searching online but can't find anything usefull or they all say me to use above formula that is not working after i filter results.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
To get the average of filtered data you need an array formula.

=AVERAGE(IF(SUBTOTAL(3,OFFSET(L7:L22800,ROW(L7:L22800)-ROW(L7),0,1)),IF(L7:L22800="Car",M7:M22800)))
confirmed with Ctrl+Shift+Enter, not just Enter

Hope this helps

M.
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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