SUBTOTAL (average) on criteria

colaps

New Member
Joined
Jan 29, 2013
Messages
37
Hello,

I have an issue and i need your assistance
Situation is like this:


[TABLE="class: grid, width: 100"]
<tbody>[TR]
[TD]Zone[/TD]
[TD][TABLE="width: 64"]
<tbody>[TR="class: grid"]
[TD="width: 64"]StoreID[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 161"]
<tbody>[TR="class: grid"]
[TD="width: 161"]Sortiments[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 81"]
<tbody>[TR="class: grid"]
[TD="width: 81"]SoldQty(Kg)[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]EU[/TD]
[TD][TABLE="width: 64"]
<tbody>[TR="class: grid"]
[TD="width: 64"]SHOP1[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]APPLE[/TD]
[TD]200[/TD]
[/TR]
[TR]
[TD]EU[/TD]
[TD][TABLE="width: 64"]
<tbody>[TR="class: grid"]
[TD="width: 64"]SHOP1[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]ORANGE[/TD]
[TD]140[/TD]
[/TR]
[TR]
[TD]EU[/TD]
[TD][TABLE="width: 64"]
<tbody>[TR="class: grid"]
[TD="width: 64"]SHOP1[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 161"]
<tbody>[TR="class: grid"]
[TD="width: 161"]ONION[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]21[/TD]
[/TR]
[TR]
[TD]EU[/TD]
[TD][TABLE="width: 64"]
<tbody>[TR="class: grid"]
[TD="width: 64"]SHOP1[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 161"]
<tbody>[TR="class: grid"]
[TD="width: 161"]POTATO[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]47
[/TD]
[/TR]
[TR]
[TD]EU[/TD]
[TD][TABLE="width: 64"]
<tbody>[TR="class: grid"]
[TD="width: 64"]SHOP1[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 161"]
<tbody>[TR="class: grid"]
[TD="width: 161"]GRAPES[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]EU[/TD]
[TD][TABLE="width: 64"]
<tbody>[TR="class: grid"]
[TD="width: 64"]SHOP1[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 161"]
<tbody>[TR="class: grid"]
[TD="width: 161"]LEMON[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]589
[/TD]
[/TR]
[TR]
[TD]EU[/TD]
[TD]SHOP1[/TD]
[TD][TABLE="width: 161"]
<tbody>[TR="class: grid"]
[TD="width: 161"]EGG[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]EU[/TD]
[TD]SHOP3[/TD]
[TD]APPLE[/TD]
[TD]34[/TD]
[/TR]
[TR]
[TD]EU[/TD]
[TD]SHOP3[/TD]
[TD]ORANGE[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]EU[/TD]
[TD]SHOP3[/TD]
[TD][TABLE="width: 161"]
<tbody>[TR="class: grid"]
[TD="width: 161"]ONION[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]450[/TD]
[/TR]
[TR]
[TD]EU[/TD]
[TD]SHOP3[/TD]
[TD]POTATO[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]EU[/TD]
[TD]SHOP3[/TD]
[TD]GRAPES[/TD]
[TD]243[/TD]
[/TR]
[TR]
[TD]EU[/TD]
[TD]SHOP3[/TD]
[TD]LEMON[/TD]
[TD]n/a[/TD]
[/TR]
[TR]
[TD]EU[/TD]
[TD]SHOP3[/TD]
[TD]EGG[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]US[/TD]
[TD]SHOP2[/TD]
[TD]APPLE[/TD]
[TD]230[/TD]
[/TR]
[TR]
[TD]US[/TD]
[TD]SHOP2[/TD]
[TD]ORANGE[/TD]
[TD]144[/TD]
[/TR]
[TR]
[TD]US[/TD]
[TD]SHOP2[/TD]
[TD][TABLE="width: 161"]
<tbody>[TR]
[TD="width: 161"]ONION[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]200[/TD]
[/TR]
[TR]
[TD]US[/TD]
[TD]SHOP2[/TD]
[TD][TABLE="width: 161"]
<tbody>[TR]
[TD="width: 161"]POTATO[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]85[/TD]
[/TR]
[TR]
[TD]US[/TD]
[TD]SHOP2[/TD]
[TD][TABLE="width: 161"]
<tbody>[TR]
[TD="width: 161"]GRAPES[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]US[/TD]
[TD]SHOP2[/TD]
[TD][TABLE="width: 161"]
<tbody>[TR]
[TD="width: 161"]LEMON[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]254[/TD]
[/TR]
[TR]
[TD]US[/TD]
[TD]SHOP2[/TD]
[TD][TABLE="width: 161"]
<tbody>[TR]
[TD="width: 161"]EGG[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]n/a[/TD]
[/TR]
</tbody>[/TABLE]



i need to have the average on the values from column " SoldQty(Kg) " in the table below.
Filter criteria is on Zone ( EU and US , and on sortiment type )

The result should look like:

[TABLE="class: grid, width: 100"]
<tbody>[TR]
[TD]Zone[/TD]
[TD]Sortiment[/TD]
[TD]Average[/TD]
[/TR]
[TR]
[TD]EU[/TD]
[TD]APPLE[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]ORANGE[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]ONION[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]POTATO[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]GRAPES[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]LEMON[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][TABLE="width: 161"]
<tbody>[TR="class: grid"]
[TD="width: 161"]EGG[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]US[/TD]
[TD]APPLE[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]ORANGE[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]ONION[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]POTATO[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]GRAPES[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]LEMON[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]EGG[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


average value for each of the sortiment ( APPLE, ONION , etc ) but for the corresponding Zone.


My idea was to use SUBTOTAL(101,range) to get the AVERAGE values even if the values are blank or text, and at the same time i need to make sure that i can have the criteria for the zone , i`m stuck at this now.

Any help is welcomed.

Thank you.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hi Colaps, You can create a Pivot Table as shown:

da6a31b9e08dce1816ce90664c1a0784.jpg
 
Upvote 0
If you get rid of the merged cells in results table, then: =IFERROR(AVERAGEIFS(D:D,A:A,LOOKUP(2,1/($L$3:L3<>""),$L$3:L3),C:C,M3),"")
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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