Calculating Weighted Average of a Data Subset

Oxon258

New Member
Joined
Oct 29, 2016
Messages
9
Hi,

I have a dataset with a variable versus depth (see below example). I want to calculate a weighted average of a calculated subset of these data, for example, the weighted average from 3.2 to, say, 8.7. I know how to calculate the weighted average of the full dataset, but not a subset, which will be determined by other parameters where the output will be the depth range (in this example 3.2 and 8.7). Any one have any ideas?
115
22
3169
47
54
6123
70.1
80.25
930
1020

<tbody>
</tbody>
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Assuming column A are the weights try:
Formula in D5
Code:
=SUMPRODUCT(--($B$2:$B$11>=$D$2),--($B$2:$B$11<=$D$3),$A$2:$A$11,$B$2:$B$11)/SUMPRODUCT(--($B$2:$B$11>=$D$2),--($B$2:$B$11<=$D$3),$A$2:$A$11)

row/col
A
B
C
D
1
Weight
Depth
2
1
15
Subset
3.2
3
2
2
8.7
4
3
169
5
4
7
5.3333
6
5
4
7
6
123
8
7
0.1
9
8
0.25
10
9
30
11
10
20

<tbody>
</tbody>
 
Upvote 0
Hi AhoyNC,

Thanks very much for your response. This has added some useful tips but I probably should've added some more detail to help people understand the probelm clearer. That said, your response helped me think about it better too. I've now added some detail :)

The values in column A are depth (always >or= depth above) and the values in column B are parameter values (could be >, = or < the above). The weight of each layer would therefore be the difference between each successive layer (see below). What I'm hoping to do is to find the weighted average of a user defined depth subset (example of 6.00 to 19.00 below).

I would like to determine the weighted average of 'Value' in column C over the user specified depth interval (E4:E5). To do this I understand I first need to interpolate the 'Value' at Depths 6.00 and 19.00. Currently I'm using the following to interpolate the 'Value' at depth 6.00 and 19.00:

=INDEX('parameter array')+('Depth'-INDEX('Depth Array','Row'))*(INDEX('parameter array','row'+1)-INDEX('parameter array','row'))/(INDEX('depth array','row+1)-INDEX('depth array','row'))

Where 'row' is =MATCH('depth','depth array')

I now need to determine the weighted average of 'Value' from 'depth' 6.00 to 19.00 allowing for the non linearity of the 'values' between these points. I found it useful to plot 'value' versus 'depth' and then plot two horizontal lines, one at 6.00 and one at 19.00 to help visualise the problem.

It would also be great if I could remove the requirement for depths to increase (e.g. 1.00 and 1.01) and instead have a step change so depths 1.00 and 1.01 could instead be 1.00 and 1.00, without affecting the calculation.

1ABCDE
2DepthWeightValue
30.000
41.00115Depth Subset6.00
51.010.011519.00
63.001.9920
73.010.01100Weighted Av. over subset????
84.501.49100
94.510.01125
108.704.1960
118.710.0160
1215.006.2920
1315.010.0170
1420.004.99100
1520.010.01250
1650.0029.99250
17
18Weighted Average
19171.674

<tbody>
</tbody>
 
Upvote 0
I have had this one solved by a friend.

I first use the interpolation formula above to calculate the parameter values at 0.1 m intervals. I then simply use AVERAGE(INDEX( "parameter value array",MATCH("top depth"):INDEX("parameter value array",MATCH("bottom depth")))
 
Upvote 0

Forum statistics

Threads
1,215,544
Messages
6,125,438
Members
449,225
Latest member
mparcado

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