Removing outliers from being counted in Average/Standard deviation functions??

Tycoons

New Member
Joined
Feb 17, 2017
Messages
7
Hi,

As a sciences undergrad, I have a number of massive lists of data that I need to sort through... Some of the averages and standard deviations are getting massively skewed as a result of outlier data.. Is there a way I can exclude these from my =St.dev or =avg function without having to manually remove them?

One my lists for example, is being sorted as
=STDEV.S(IF($B$13:$B$322="Bacteria Size",I$13:I$322))... is there any way I can incorporate some sort of filter that will exclude massive outliers (Both (+) and (-)) from that equation?

Really appreciate any advice. Thanks.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Assuming you consider an outlier to be +/- 1.5 times the IQR, then maybe something like below.

Use the QUARTILE function to calculate the 3rd and 1st quartiles.
Subtract the 2 to get your interquartile range (IQR)
Use this to calculate the Upper and Lower bounds.

You can then use the AVERAGEIFS function.
The standard deviation formula in cell D10 below is an array function and must be entered with CTRL-SHIFT-ENTER.

You might also wnt to look at the TRIMMEAN function.
Excel Workbook
ABCD
1Data
2453rd Qt.38
3211st Qt25
425Interquartile Range13
5101
636Upper Bound57.5
7-12Lower Bound5.5
835
938Average32.571
1028Standard Dev.8.3038
Sheet
 
Upvote 0
I think the Quartile function works great, but I can't seem to get it to work if I also try to filter out the data that I'm trying to average (I have bacteria size, Virus size etc)..... for example

=Quartile(IF($B$13:$B$322="Bacteria Size",I$13:I$322),3)
=Quartile(IF(
$B$13:$B$322="Bacteria Size",I$13:I$322),1)

But it returns a #Value!... what do I need to do to make this work?

Thanks again!
 
Upvote 0
Assuming you consider an outlier to be +/- 1.5 times the IQR, then maybe something like below.

Use the QUARTILE function to calculate the 3rd and 1st quartiles.
Subtract the 2 to get your interquartile range (IQR)
Use this to calculate the Upper and Lower bounds.

You can then use the AVERAGEIFS function.
The standard deviation formula in cell D10 below is an array function and must be entered with CTRL-SHIFT-ENTER.

You might also wnt to look at the TRIMMEAN function.

*ABCD
***
*3rd Qt.
*1st Qt
*Interquartile Range
***
*Upper Bound
*Lower Bound
***
*Average
*Standard Dev.

<colgroup><col style="width:30px; "><col style="width:64px;"><col style="width:22px;"><col style="width:135px;"><col style="width:64px;"></colgroup><tbody>
[TD="bgcolor: #cacaca, align: center"]1[/TD]
[TD="bgcolor: #c0c0c0, align: center"]Data[/TD]

[TD="bgcolor: #cacaca, align: center"]2[/TD]
[TD="align: center"]45[/TD]

[TD="align: right"]38[/TD]

[TD="bgcolor: #cacaca, align: center"]3[/TD]
[TD="align: center"]21[/TD]

[TD="align: right"]25[/TD]

[TD="bgcolor: #cacaca, align: center"]4[/TD]
[TD="align: center"]25[/TD]

[TD="align: right"]13[/TD]

[TD="bgcolor: #cacaca, align: center"]5[/TD]
[TD="align: center"]101[/TD]

[TD="bgcolor: #cacaca, align: center"]6[/TD]
[TD="align: center"]36[/TD]

[TD="align: right"]57.5[/TD]

[TD="bgcolor: #cacaca, align: center"]7[/TD]
[TD="align: center"]-12[/TD]

[TD="align: right"]5.5[/TD]

[TD="bgcolor: #cacaca, align: center"]8[/TD]
[TD="align: center"]35[/TD]

[TD="bgcolor: #cacaca, align: center"]9[/TD]
[TD="align: center"]38[/TD]

[TD="align: right"]32.571[/TD]

[TD="bgcolor: #cacaca, align: center"]10[/TD]
[TD="align: center"]28[/TD]

[TD="align: right"]8.3038[/TD]

</tbody>

Spreadsheet Formulas
CellFormula
D2=QUARTILE(A2:A10,3)
D3=QUARTILE(A2:A10,1)
D4=D2-D3
D6=D2+1.5*D4
D7=D3-1.5*D4
D9=AVERAGEIFS(A2:A10,A2:A10,"<="&D6,A2:A10,">="&D7)
D10{=STDEV.S(IF(A2:A10<=D6,IF(A2:A10>=D7,A2:A10)))}

<tbody>
</tbody>
Formula Array:
Produce enclosing
{ } by entering
formula with CTRL+SHIFT+ENTER!

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie Html" target="_blank"> Excel Jeanie HTML 4


So I've got the interquartile range all sorted...

But my Stdev and AVG formula is a mess.. any chance you can help me fix this up?

=AVERAGEIFS($B$13:$B$322="Bacteria Size",I$13:I$322,if($B$13:$B$322,$B$13:$B$322,,"<="&D6,A2:A10,">="&D7))

{=STDEV.S(IF$B$13:$B$322="Bacteria Size",I$13:I$322,if($B$13:$B$322,$B$13:$B$322,,"<="&D6,A2:A10,">="&D7))
 
Upvote 0
See if this helps (Note: AVERAGEIFS function is in Excel 2010 and later, if you have an earlier ver. of Excel we will need to use an array function).

Also, the Standard Dev. formula is an array and must be entered with CTRL-SHIFT-ENTER.
Excel Workbook
ABCDEFGHI
1
23rd Qt.38
31st Qt25
4Interquartile Range13
5
6Upper Bound57.5
7Lower Bound5.5
8
9Average32.571
10Standard Dev.8.3038
11
1232.571Data
13Bacteria Size45
14test100
15Bacteria Size21
16test200
17test300
18Bacteria Size25
19Bacteria Size101
20Bacteria Size36
21Bacteria Size-12
22Bacteria Size35
23Bacteria Size38
24Bacteria Size28
Sheet
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

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