Conditional calculation of the standard deviation.

TPFKAS

Board Regular
Joined
Mar 1, 2010
Messages
58
Hi there,

I have a table with two columns (a1:b200).
I need to calculate the standard deviation of the values in column B, but only for those values where a condition in column A is being met.
For example: column A contains only the numbers 0 and 1 and I want only to include all numbers in column B in the calculation of the standard deviation where the value in column A is 1.

Can this easily be done with a single formula?

Thanks in Advance!
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Sure, for example:

ABCDE
1Col ACol B
20748307.8342.1146
31328
40833
51876
60820
70511
80441
90943
101824
110575
120974
130811
14199
150494
161174
171870
181890
191182
20097
210493
221390
23044
240567
251165

<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet4

Worksheet Formulas
CellFormula
D2=STDEV.S(B2:B25)

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

Array Formulas
CellFormula
E2{=STDEV.S(IF($A$2:$A$25=1,$B$2:$B$25))}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>



If your standard deviation formula is D2, then the E2 array formula only includes the values where column A = 1. Make sure to enter it with Control+Shift+Enter.
 
Upvote 0
Thanks for your prompt reply.
Works like a charm. I was just reading some stuff about array operations. Never knew about it before. Another extra piece of wisdom. ?
 
Upvote 0
I don't think anyone knows all the tricks of Excel! Arrays are particularly obscure, and particularly useful! Glad this one works for you. :cool:
 
Upvote 0

Forum statistics

Threads
1,215,695
Messages
6,126,263
Members
449,307
Latest member
Andile

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