• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Excel Average IF Excluding Outliers

You are here: Home / Excel Formulas / Excel Average IF Excluding Outliers
Excel Average IF Excluding Outliers
October 2, 2013 by Mynda Treacy

I stumbled upon an interesting question the other day, which was; β€˜how do I find the average of a range of numbers that meet criteria, and by the way, I want to exclude the outliers?’

Now, if all we needed was a simple average that met criteria we could use an AVERAGEIF or AVERAGEIFS formula.

Or if we just wanted to exclude the outliers we could use the TRIMMEAN function which returns the mean (average) of the interior proportion of values.

The syntax is:

TRIMMEAN(array, percent)

Where the array is the range containing your values and percent is the fractional number of data points you want to exclude from the top and bottom of your data set.

But we want to effectively find the AVERAGEIF and TRIMMEAN.

Unfortunately this pair don’t get on so well in the same cell so I’ve got an alternative and it’s not called TRIMMEANIF….but maybe there’s an idea.

Note to self; write to Microsoft suggesting new TRIMMEANIF function!

Ok, let’s take this list as our example:

Excel Average IF excluding top and bottom values

And let’s say we want to find the average Units for Size 8 and exclude the top and bottom 40%.

Note: you wouldn’t normally exclude 40% of your sample but since mine is so small (so it’ll easily fit on the screen) I have had to make the proportion to exclude quite large.

Here’s the formula:

=TRIMMEAN(IF(B2:B12=8,C2:C12),40%)

It’s an array formula so you need to enter it with CTRL+SHIFT+ENTER.

In English it reads: Find the MEAN (average) of the values in the range C2:C12, where the size in the range B2:B12 is 8, oh, and by the way, ignore the top and bottom 40% of the values.

My nested IF formula returns an array of Units that are size 8, and if we step through how the formula evaluates we can see it looks like this:

Step 1: Evaluate the IF formula logical test and expand the range C2:C12

=TRIMMEAN(IF({TRUE;TRUE;TRUE;TRUE;TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE}, {2;4;5;6;9;4;10;8;9;4;1}), 40%)

Step 2: create an array of the values that evaluate to TRUE

=TRIMMEAN({2;4;5;6;9}, 40%)

Step 3: strip out the outliers from the array of values

=TRIMMEAN({4;5;6})

Step 4: find the mean (average) of the remaining values

=5

Note: if you run this formula through the Evaluate Formula tool you will see it work through the steps above.

Average Top 3 Values

Another member of the Average family that you might find useful is the AVERAGE LARGE formula which finds the average of the top 3 values.

Excel Average IF Excluding Outliers

More Average Posts

More Excel Formulas Posts

ai-aided excel formula editor

AI Aided Excel Formula Editor

Save time with this free AI Excel formula editor add-in that writes, edits, improves and interprets formulas for you!
top excel functions for data analysts

Top Excel Functions for Data Analysts

Must know Excel Functions for Data Analysts and what functions you don’t have to waste time learning and why.
excel advanced formula environment

Excel Advanced Formula Environment

Excel Advanced Formula Environment is a long awaited, new improved way to write, name and store Excel formulas.
Pro Excel Formula Writing Tips

Pro Excel Formula Writing Tips

Must know Excel formula writing tips, tricks and tools to make you an Excel formula ninja, including a new formula editor.
excel shaping arrays

New Array Shaping Excel Functions

The Excel Shaping Array Functions makes it easier than ever to reshape arrays and ranges using these purpose built functions
excel nested if functions what not to do

Excel IF Formulas and What Not To Do

Excel IF formulas can get out of hand when you nest too many IFs. Not only do they become unwieldy they’re difficult for anyone to understand
excel image function

Excel IMAGE Function

The Excel IMAGE Function enables you to embed images in a cell using a formula. It supports BMP, JPG/JPEG, GIF, TIFF, PNG, ICO, and WEBP files

Excel VSTACK and HSTACK Functions

New Excel VSTACK and HSTACK functions makes combining arrays of cells easy and with some clever tricks we can extend their capabilities.
identify overlapping dates and times in excel

Identify overlapping dates and times in Excel

How to identify overlapping dates and times in Excel with a formula that checks a range of cells. Works with Dates and Times.
New Excel Text Functions

TEXTSPLIT, TEXTBEFORE and TEXTAFTER Functions

TEXTAFTER, TEXTBEFORE and TEXTSPLIT are exciting new Excel Text functions. They’re fairly self-explanatory, however TEXTSPLIT has some cool features.


Category: Excel FormulasTag: average
Previous Post:Merge Excel Worksheets with VBAMerge Excel Worksheets with VBA
Next Post:Return the First and Last Values in a RangeReturn the First and Last Values in a Range

Reader Interactions

Comments

  1. Istvan

    January 22, 2018 at 4:08 am

    Hi Guys,

    It works for me, does what it is supposed to, however, is there any way to make it faster by replacing the IF part somehow?
    I mean, I have a huge data on 2-3 different tabs and I need to calculate trimmed mean along with percentile 2 times for min and max and it is very slow to update anything. Is the IF part replaceable by alternative like INDEX/MATCH? Would it be faster? Any Idea? Thanks.

    Reply
    • Mynda Treacy

      January 22, 2018 at 8:32 am

      Hi Istvan,

      It’s difficult to offer an alternative without seeing your scenario and criteria for the mean. It might be that you can use PivotTables, or maybe Power Query to extract the data excluding the outliers. Please post your question on our Excel forum and include a sample Excel file. From here we can help you better.

      Mynda

      Reply
  2. MauroV

    September 20, 2017 at 9:25 am

    Alternative, ommiting top 5%:
    =AVERAGE(INDIRECT(“BH”&COUNTA(BH:BH)-ROUNDDOWN(COUNTA(BH:BH)*0.95,0)&”:BH”&COUNTA(BH:BH)))

    Assuming BH is where you have your data range, and that your data range is sorted descending.
    πŸ™‚
    If you sort it ascending, you get the bottom 5% ignored. πŸ™‚

    Reply
  3. Liz

    August 22, 2017 at 6:16 pm

    Perfect! Thank you. It was exactly what I needed (although I would have saved myself 20 minutes if I had read the next line about the array Ctrl Shift Enter).

    Reply
    • Mynda Treacy

      August 22, 2017 at 6:33 pm

      πŸ™‚ glad it was useful and you got there in the end.

      Reply
  4. Debbie Dyche

    May 5, 2016 at 5:17 am

    How do I get an average cost per sale from a pivot table??? I can’t find anything on averages for pivot tables.

    Reply
    • Mynda Treacy

      May 5, 2016 at 8:49 am

      Hi Debbie,

      I’m assuming you’re talking about regular PivotTables and not Power Pivot? If so then you could try using a calculated field:

      https://www.myonlinetraininghub.com/excel-pivottable-calculated-fields

      Note: you should know that a PivotTable aggregates the data and then performs the calculation on the values in each row. I assume you will have columns for Total Costs and Count of Sales. Depending on the level of detail you drill down to in your row labels, dividing Total Costs by Count of Sales may, or may not give you the average you had in mind.

      Mynda

      Reply
  5. Duncan

    November 7, 2013 at 9:14 pm

    I like this blog! It reminds me of what happens in my training room. I often say, you ask me questions that I never think about because I can’t walk in your shoes. Then I enjoy solving their problems.

    The same here, lots of interesting problems and solutions to keep the grey cells ticking. Not always earth shattering but then they don’t have to be, do they?

    Duncan

    Reply
    • Mynda Treacy

      November 7, 2013 at 9:16 pm

      Cheers, Duncan. Glad to help keep your grey cells alive πŸ™‚

      Reply
  6. Leslie Glasser

    October 3, 2013 at 11:39 am

    Although Excel offers the TRIMMEAN function, it does not seem to be the statistically best measure of ‘central tendency’ since it relies on arbitrary selection of the proportions of the data to be excluded and (worse) assumes that the data spread is symmetrical.

    A more satisfactory measure is MEDIAN which is the central value (or mean of two if there is a even number of data points), thus automatically excluding outliers on both ends of the data. Technically, it is a more ‘robust’ measure than TRIMMEAN.

    Reply
    • Mynda Treacy

      October 3, 2013 at 12:06 pm

      Thanks for your wisdom, Leslie πŸ™‚

      If you’d like to calculate the MEDIAN IF the formula would be:

      =MEDIAN(IF(B2:B12=8,C2:C12))

      Entered as an array formula with CTRL+SHIFT+ENTER.

      Kind regards,

      Mynda.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Current ye@r *

Leave this field empty

Sidebar

More results...

Featured Content

  • 10 Common Excel Mistakes to Avoid
  • Top Excel Functions for Data Analysts
  • Secrets to Building Excel Dashboards in Less Than 15 Minutes
  • Pro Excel Formula Writing Tips
  • Hidden Excel Double-Click Shortcuts
  • Top 10 Intermediate Excel Functions
  • 5 Pro Excel Dashboard Design Tips
  • 5 Excel SUM Function Tricks
  • 239 Excel Keyboard Shortcuts

100 Excel Tips and Tricks eBook

Download Free Tips & Tricks

Subscribe to Our Newsletter

Receive weekly tutorials on Excel, Power Query, Power Pivot, Power BI and More.

We respect your email privacy

Guides and Resources

  • Excel Keyboard Shortcuts
  • Excel Functions
  • Excel Formulas
  • Excel Custom Number Formatting
  • ALT Codes
  • Pivot Tables
  • VLOOKUP
  • VBA
  • Excel Userforms
  • Free Downloads

239 Excel Keyboard Shortcuts

Download Free PDF

Free Webinars

Excel Dashboards Webinar

Watch our free webinars and learn to create Interactive Dashboard Reports in Excel or Power BI

Click Here to Watch Now

mynda treacy microsoft mvpHi, I'm Mynda Treacy and I run MOTH with my husband, Phil. Through our blog, webinars, YouTube channel and courses we hope we can help you learn Excel, Power Pivot and DAX, Power Query, Power BI, and Excel Dashboards.

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk – For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.