Subtotal with Averageif

kumara_faith

Well-known Member
Joined
Aug 19, 2006
Messages
951
Office Version
  1. 365
Hi,

I have the following table:

DateBranchStaffProductivity Rate
Monday, 2 January, 2023TexasStaff195%
Monday, 2 January, 2023TexasStaff298%
Monday, 2 January, 2023TexasStaff30%
Monday, 2 January, 2023TexasStaff40%
Monday, 2 January, 2023TexasStaff596%
Tuesday, 3 January, 2023TexasStaff195%
Tuesday, 3 January, 2023TexasStaff20%
Tuesday, 3 January, 2023TexasStaff30%
Tuesday, 3 January, 2023TexasStaff487%
Tuesday, 3 January, 2023TexasStaff585%
Wednesday, 4 January, 2023TexasStaff10%
Wednesday, 4 January, 2023TexasStaff20%
Wednesday, 4 January, 2023TexasStaff395%
Wednesday, 4 January, 2023TexasStaff492%
Wednesday, 4 January, 2023TexasStaff593%
SubtotalSubtotalSubtotal56%


I am trying to build a subtotal formula so that when we filter by dates or staff, we will be able to see the average productivity rate for the selected dates. The average productivity should however only calculate cells more than zero.

Example , for the selection below, the correct average productivity is 96% and not 56%. Is there a way to add the additional condition into this formula ? Appreciate all the help.


DateBranchStaffProductivity Rate
Monday, 2 January, 2023TexasStaff195%
Monday, 2 January, 2023TexasStaff298%
Monday, 2 January, 2023TexasStaff30%
Monday, 2 January, 2023TexasStaff40%
Monday, 2 January, 2023TexasStaff596%
SubtotalSubtotalSubtotal58%
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
why not try something like:
Excel Formula:
=SUMIF(D2:D100,">0",D2:D23)/COUNTIF(D2:D100,">0")
 
Upvote 0
Hi offthelip,

Thank you for the suggestion. The reason I wanted to use subtotal is for the users to be able to filter to any dates or staff, and the productivity rate will changes accordingly by calculating the selected cells and ignoring zero. The formula suggested above will only show a static result and will not be able to change according to the selection. Appreciate the help.
 
Upvote 0
How about with a helper column
Fluff.xlsm
ABCDE
1DateBranchStaffProductivity Rate
2Monday, 2 January, 2023TexasStaff195%1
3Monday, 2 January, 2023TexasStaff298%1
4Monday, 2 January, 2023TexasStaff30%1
5Monday, 2 January, 2023TexasStaff40%1
6Monday, 2 January, 2023TexasStaff596%1
7Tuesday, 3 January, 2023TexasStaff195%1
8Tuesday, 3 January, 2023TexasStaff20%1
9Tuesday, 3 January, 2023TexasStaff30%1
10Tuesday, 3 January, 2023TexasStaff487%1
11Tuesday, 3 January, 2023TexasStaff585%1
12Wednesday, 4 January, 2023TexasStaff10%1
13Wednesday, 4 January, 2023TexasStaff20%1
14Wednesday, 4 January, 2023TexasStaff395%1
15Wednesday, 4 January, 2023TexasStaff492%1
16Wednesday, 4 January, 2023TexasStaff593%1
17SubtotalSubtotalSubtotal93%
Main
Cell Formulas
RangeFormula
E2:E16E2=SUBTOTAL(103,A2)
D17D17=AVERAGEIFS(D2:D16,D2:D16,">0",E2:E16,1)


Fluff.xlsm
ABCDE
1DateBranchStaffProductivity Rate
2Monday, 2 January, 2023TexasStaff195%1
3Monday, 2 January, 2023TexasStaff298%1
4Monday, 2 January, 2023TexasStaff30%1
5Monday, 2 January, 2023TexasStaff40%1
6Monday, 2 January, 2023TexasStaff596%1
17SubtotalSubtotalSubtotal96%
Main
Cell Formulas
RangeFormula
E2:E6E2=SUBTOTAL(103,A2)
D17D17=AVERAGEIFS(D2:D16,D2:D16,">0",E2:E16,1)
 
Upvote 0
Solution
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,659
Messages
6,173,636
Members
452,525
Latest member
DPOLKADOT

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