# Return a summing and averaging filtered gain or losses values.

#### mmr1

##### Board Regular
Hi,

As in a sample sheet enclosed herein the data contains three columns and headers like weeks, location and Gain or Loss, I already worked out for Sum and Average (Column C27:C30) of values gain and loss (unfiltered category)

I am looking a formula for Sum and Average (Column C32:C35) of values gain and loss (filtered category) where Sum and Average gain and loss values to be returns as per filtered headers of column A or B, for example If I apply filter to Area1 criteria of Column B then sum and Average values to be return as per filtered criteria.

Thanks for the help.

Summing and averaging filtered and unfiltered list separately for gain and losess.xlsx
ABC
1
2WeeksLocationGain or Loss
3Week1Area 1(4,540.00)
4Week1Area 21,565.00
5Week1Area 3(1,937.00)
6Week2Area 11,986.00
7Week2Area 2(1,880.00)
8Week2Area 31,763.00
9Week3Area 11,808.00
10Week3Area 21,468.00
11Week3Area 3(2,286.00)
12Week4Area 1(2,635.00)
13Week4Area 22,451.00
14Week4Area 31,829.00
15Week5Area 1(1,257.00)
16Week5Area 29,332.00
17Week5Area 311,070.00
18Week6Area 11,647.00
19Week6Area 2(2,230.00)
20Week6Area 31,180.00
21Week7Area 1(2,259.00)
22Week7Area 2(12,036.00)
23Week7Area 36,565.00
24
25
26
27Total Sum of Gain (Unfiltred)42,664.00
28Total Sum of Loss (Unfiltered)(26,520.00)
29Total Average of Gain (Unfiltered)3,555.33
30Total Average of Loss (Unfiltered)(3,451.11)
31
32Total Sum of Gain (filtred)
33Total Sum of Loss (filtered)
34Total Average of Gain (filtered)
35Total Average of Loss (filtered)
Sheet1
Cell Formulas
RangeFormula
C27C27=SUMIF(\$C\$3:\$C\$23,">0")
C28C28=SUMIF(\$C\$4:\$C\$24,"<0")
C29C29=AVERAGEIF(\$C\$3:\$C\$23,">0")
C30C30=AVERAGEIF(\$C\$3:\$C\$23,"<0")

### Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

#### mmr1

##### Board Regular
Hi,

Could someone look into this query i actually seeking a formula for subtotals sum and average for positive and negative values.

#### Fluff

##### MrExcel MVP, Moderator
+Fluff v2.xlsm
ABC
1
2WeeksLocationGain or Loss
3Week1Area 1(4,540.00)
4Week1Area 21,565.00
5Week1Area 3(1,937.00)
6Week2Area 11,986.00
7Week2Area 2(1,880.00)
8Week2Area 31,763.00
9Week3Area 11,808.00
10Week3Area 21,468.00
11Week3Area 3(2,286.00)
12Week4Area 1(2,635.00)
13Week4Area 22,451.00
14Week4Area 31,829.00
15Week5Area 1(1,257.00)
16Week5Area 29,332.00
17Week5Area 311,070.00
18Week6Area 11,647.00
19Week6Area 2(2,230.00)
20Week6Area 31,180.00
21Week7Area 1(2,259.00)
22Week7Area 2(12,036.00)
23Week7Area 36,565.00
24
25
26
27Total Sum of Gain (Unfiltred)42,664.00
28Total Sum of Loss (Unfiltered)(31,060.00)
29Total Average of Gain (Unfiltered)3,555.33
30Total Average of Loss (Unfiltered)(3,451.11)
31
32Total Sum of Gain (filtred)42,664.00
33Total Sum of Loss (filtered)(31,060.00)
34Total Average of Gain (filtered)3,555.33
35Total Average of Loss (filtered)(3,451.11)
Clubs
Cell Formulas
RangeFormula
C27C27=SUMIF(\$C\$3:\$C\$23,">0")
C28C28=SUMIF(\$C\$3:\$C\$23,"<0")
C29C29=AVERAGEIF(\$C\$3:\$C\$23,">0")
C30C30=AVERAGEIF(\$C\$3:\$C\$23,"<0")
C32C32=SUMPRODUCT(SUBTOTAL(9,OFFSET(\$C\$3,ROW(\$C\$3:\$C\$23)-ROW(\$C\$3),0,1)),--(\$C\$3:\$C\$23>0))
C33C33=SUMPRODUCT(SUBTOTAL(9,OFFSET(\$C\$3,ROW(\$C\$3:\$C\$23)-ROW(\$C\$3),0,1)),--(\$C\$3:\$C\$23<0))
C34C34=AVERAGE(IF(C3:C23>0,IF(SUBTOTAL(2,OFFSET(C3,ROW(C3:C23)-ROW(C3),0)),C3:C23)))
C35C35=AVERAGE(IF(C3:C23<0,IF(SUBTOTAL(2,OFFSET(C3,ROW(C3:C23)-ROW(C3),0)),C3:C23)))

 Weeks Location Gain or Loss Week1 Area 1 (4,540.00) Week2 Area 1 1,986.00 Week3 Area 1 1,808.00 Week4 Area 1 (2,635.00) Week5 Area 1 (1,257.00) Week6 Area 1 1,647.00 Week7 Area 1 (2,259.00) Total Sum of Gain (Unfiltred) 42,664.00 Total Sum of Loss (Unfiltered) (31,060.00) Total Average of Gain (Unfiltered) 3,555.33 Total Average of Loss (Unfiltered) (3,451.11) Total Sum of Gain (filtred) 5,441.00 Total Sum of Loss (filtered) (10,691.00) Total Average of Gain (filtered) 1,813.67 Total Average of Loss (filtered) (2,672.75)

#### mmr1

##### Board Regular
Thank you so much fluff for being supportive always and provided nice solution to the query.

#### Fluff

##### MrExcel MVP, Moderator
Glad to help & thanks for the feedback.

Replies
1
Views
350
Replies
3
Views
57
Replies
6
Views
125
Replies
2
Views
63
Replies
3
Views
211

1,128,165
Messages
5,629,068
Members
416,363
Latest member
zaveedd

### 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.

### Which adblocker are you using?

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

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