Average function that stops counting if another argument is met

Krabben

New Member
Joined
Aug 19, 2020
Messages
12
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello Mr. excel forum :)

I'm looking for a formula that can find the average that stops counting if another argument is met.

In the picture below, i've divided it into 5 different "layers".
In these layers, the average value of the numbers in the column A, should be given in column C, if the number in the column B matches eachother.

1604935413001.png


Hope you guys understand my question. Any ideas?


Thanks
 
My formula included an extra row below the data set specifically so there would always be a change. (Note that the data I posted went down to row 24 but the formula included row 25.)
 
Upvote 0

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
My formula included an extra row below the data set specifically so there would always be a change. (Note that the data I posted went down to row 24 but the formula included row 25.)
Book1
ABCD
1Depth (meter)ValueBandAverage
21595,2
32395,2
43695,2
54495,2
65895,2
76152,7
87252,7
98552,7
109665,0
1110465,0
1211355,5
1312855,5
141376#N/A
151466#N/A
161556#N/A
171636#N/A
181716#N/A
191806#N/A
201986#N/A
212016#N/A
222136#N/A
232256#N/A
242396#N/A
252456#N/A
262556#N/A
272656#N/A
282756#N/A
292856#N/A
302956#N/A
313056#N/A
323156#N/A
333256#N/A
343356#N/A
Sheet1
Cell Formulas
RangeFormula
D2:D34D2=IF(C2=C1,D1,AVERAGE(B2:INDEX(B2:B16,MATCH(TRUE,C2:C16<>C2,0)-1)))



So here i've updated my #1 post with a Depth column. My average function should always consider a depth of 15 meters and should consider the "band" groups in this range.
Therefor, when the formula gets dragged down to D14 and further, it results in #N/A.
 
Upvote 0
That is a completely different requirement since it's a rolling range, not a static one. On that basis, it would seem that the results in column D shouldn't be repeating any more, in which case, you could use:

=AVERAGE(B2:INDEX(B2:B16,IFERROR(MATCH(TRUE,C2:C16<>C2,0)-1,15)))
 
Upvote 0
Solution

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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