Average excluding top 5% of values for specific dates and one additional criterion

Losttexan

New Member
Joined
Jul 5, 2017
Messages
2
Normally can find the answers to my questions within this forum but have been searching off and on for a couple of days without luck (yet). Hoping you can help!

I am trying to calculate the average of Value/column C below per Date/column A only when Type/column B = 1 and excluding the top 5% of numerical results in Value/column C.

The example below is simplified, with only 20 Type 1 values per date but I could have many hundreds or thousands of that type on any given date. Using this sample, I want to find the average of 'Value' for all Type 1 entries where Date = May-01-2017, excluding the first row (5745) because it is in the top 5% of values for that date and type.

I've tried multiple approaches (nested IF arrays/AverageIFs/SumIFs trying to use the LARGE function within that array) but always keep coming back only with the overall average of Type 1s for each date. Example:

=AVERAGEIFS(A2:A41,May-01-2017,B2:B41,1,C2:C41,"<"&LARGE(C2:C41,COUNTIFS(B2:B41,1,A2:A41,May-01-2017)*0.05))

Not sure I translated all of the parentheses above properly when extracting it from my source but each attempt of this type returns the overall average of Type = 1 for the specified date. I think the LARGE function isn't being properly constrained into the array of "Date = May-01-2017 and Type = 1".

None of the data cells will contain null values although zeroes are frequently present.

Please let me know if I can provide an additional information and thank you in advance.



DateTypeValue
May-01-201715745
May-01-201711064
May-01-20171232
May-01-20171108
May-01-2017199
May-01-2017148
May-01-20171109
May-01-20171284
May-01-2017
1182
May-01-20171190
May-01-20171558
May-01-20171141
May-01-20171147
May-01-20171188
May-01-201711414
May-01-20171256
May-01-2017189
May-01-20171304
May-01-201710
May-01-201710
May-01-201729
May-01-2017214
May-01-20172186
May-01-20172512
May-01-2017216125
May-01-201721414
May-01-201728214
May-01-201723614
May-01-2017285
May-01-201720
May-01-201725979
May-01-201723507
May-01-20172232
May-01-20172478
May-01-201721938
May-01-201725663
May-01-2017214
May-01-2017237
May-01-20172426
May-01-201721447
May-02-201716125
May-02-2017114
May-02-201710
May-02-201710
May-02-2017119
May-02-20171187
May-02-20171223
May-02-20171414
May-02-20171370
May-02-2017116
May-02-201710
May-02-2017129
May-02-2017137
May-02-20171177
May-02-20171806
May-02-2017124
May-02-2017199
May-02-20171704
May-02-2017191
May-02-20171400
May-02-2017223
May-02-2017
21847
May-02-201729154
May-02-2017214
May-02-201720
May-02-20172808
May-02-20172627
May-02-20172505
May-02-20172413
May-02-20172399
May-02-20172211
May-02-20172197
May-02-201728
May-02-201720
May-02-2017227
May-02-201729414
May-02-2017282
May-02-20172187
May-02-201728714

<tbody>
</tbody>
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Welcome to the forum.

Here's your problem:

=AVERAGEIFS(A2:A41,May-01-2017,B2:B41,1,C2:C41,"<"&LARGE(C2:C41,COUNTIFS(B2:B41,1,A2:A41,May-01-2017)*0.05))

You're properly finding that there are 20 matching rows, and 20 * .05 =1, but then you're using the entire range in the LARGE, so you're getting the largest value (16125), even though it's not a matching row. So 5745 would be included.


You could try something like this:
=AVERAGEIFS(C2:C41,A2:A41,DATE(2017,4,1),B2:B41,1,C2:C41,"<"&LARGE(IF((A2:A41=DATE(2017,4,1))*(B2:B41)=1,C2:C41),COUNTIFS(B2:B41,1,A2:A41,DATE(2017,4,1))*0.05))

confirmed with Control+Shift+Enter.

Note the C2:C41 at the start of the formula, and I used different a different date function. Use what works for you.
 
Last edited:
Upvote 0
Eric,

I think you nailed it... working as expected once I included your conditions within the LARGE formula. Thanks!
 
Upvote 0

Forum statistics

Threads
1,215,635
Messages
6,125,942
Members
449,275
Latest member
jacob_mcbride

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