Which Function

rssl2000

New Member
Joined
Oct 18, 2017
Messages
26
Hello,
I'm trying to figure out which function or combination of functions to use. I'm trying to take the average from one column of data, but the data is chosen from another column of data, but in the same row. In the example below, column A is the criteria, but I want the number averaged to come from row B. So if I choose "1", the average is (15+19)=17.

A B
1 15
2 13
3 10
1 19
2 22
3 17

Thanks, Adam
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
This is all based on one particular year, the year 2000.
Then I fail to understand how you could have a Beginning value (348) that is greater than your Ending value (15).
Why would you even have that situation? What is that supposed to mean?
By definition, the Beginning value should not be less than the Ending value.

So I am not sure i understand that you are trying to do with that.
Are you trying to take the average of two distinctly unrelated time periods at once (i.e. the first 15 days of the year, and the last 18 days of the year)?
 
Last edited:
Upvote 0
Correct, I'm looking at utility bills. And most times the bill start in December and end in January. So I need both December and January dates to create my average.
 
Upvote 0
OK, then we need to check to see if T12 is greater than U12, and if so, we need to average the two end ranges.
It looks a little messy, but this should work:
Code:
=IF([COLOR=#0000ff]T12>U12[/COLOR],[COLOR=#ff0000](SUMIFS($F$2:$F$8761,$B$2:$B$8761,">=" & T12)+SUMIFS($F$2:$F$8761,$B$2:$B$8761,"<=" & U12))/(COUNTIF($B$2:$B$8761,">=" & T12)+COUNTIF($B$2:$B$8761,"<=" & U12))[/COLOR][COLOR=#008000],AVERAGEIFS($F$2:$F$8761,$B$2:$B$8761,">=" & T12,$B$2:$B$8761,"<=" & U12))[/COLOR]

Since we are now average an OR situation (less than the smaller number combined with greater than the larger number), we have to manually do the average by summing up all the values and dividing by the counts.
I color coded it so you can more easily see the different sections.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,631
Messages
6,120,645
Members
448,974
Latest member
DumbFinanceBro

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