• 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
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member
  • Login

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
Mynda Treacy

Microsoft MVP logo

AUTHOR Mynda Treacy Co-Founder / Owner at My Online Training Hub

CIMA qualified Accountant with over 25 years experience in roles such as Global IT Financial Controller for investment banking firms Barclays Capital and NatWest Markets.

Mynda has been awarded Microsoft MVP status every year since 2014 for her expertise and contributions to educating people about Microsoft Excel.

Mynda teaches several courses here at MOTH including Excel Expert, Excel Dashboards, Power BI, Power Query and Power Pivot.

More Average Posts

More Excel Formulas Posts

Summarize Months to Quarters

Excel Formulas to Summarise Monthly Data into Quarters

3 ways (good, better, best) to summarize monthly data into quarters using formulas. Lots of examples and sample file to download.
Excel BYROW and BYCOL Functions

Excel BYCOL and BYROW Functions

Excel BYCOL and BYROW functions fundamentally change the way we write formulas that calculate across columns and down rows.
python in excel natively

How to Use Python in Excel Natively

How to use Python in Excel natively using libraries like Pandas, NumPy, Matplotlib, Seaborn and more for analysis and spectacular charts!
excel dynamic named ranges

Excel Dynamic Named Ranges

Excel Dynamic Named Ranges update automatically to include new data in the ranges referenced in your formulas and PivotTables etc.
functions for financial modelling

Excel Functions for Financial Modeling

Top 23 must know Excel functions for Financial Modeling. Includes example Excel file and step by step instructions.
excel formula by example

Excel Formula by Example

Excel can now write a formula by example. Simply give it an example or two of the result and Excel will write the formula.
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 Labs (Formerly, Advanced Formula Environment)

Excel Labs is a long awaited, new improved way to write, name and store Excel formulas, including LAMBDAS with the help of AI.
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.


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...

Popular 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

239 Excel Keyboard Shortcuts

Download Free PDF

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 Office Scripts
  • 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

Sign up to our newsletter and join over 400,000
others who learn Excel and Power BI with us.

 

Company

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

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.