简体   繁体   中英

Excel: calculate STDEV of cells in second column which their first column cell values are in between the number in other 2 cells

I tried :

=STDEV(IF((COUNTIFS(AM$9:AM$89,">"&AP10,AM$9:AM$89,"<="&AP11)),AN9:AN89))

It gave me the STDEV of whole second column.

The main objective is I want to make histogram with their standard deviation as an error bar.

You can solve this in 2 steps. First, you will need an Array Formula, which works similar to what you are attempting with your countifs function. In short, it takes a whole range of values and uses then to run the formula multiple times, spitting out an array of answers. To get your array of numbers larger than AP10, do this:

=IF(AM3:AM89>AP10,AM3:AM89,"")

To confirm this formula, press CTRL + SHIFT + ENTER instead of just ENTER. This will give you a range of values from AM3:AM89, with a blank replacing any value not bigger than AP10. These blank values will be ignored by the STDEV formula. So just wrap the above array formula in STDEV as in the below, and you're done:

=STDEV(IF(AM3:AM89>AP10,AM3:AM89,""))

Remember - confirm with CTRL + SHIFT + ENTER instead of just ENTER. For background on array formulas, see here: http://spreadsheets.about.com/od/excelfunctions/ss/2011-03-23-excel-2010-multi-cell-array-formula-sbs-tutorial.htm

The standard set-up would be the array formula** :

=STDEV(IF(AM$9:AM$89>AP10,IF(AM$9:AM$89<=AP11,AN9:AN89)))

although it's interesting to note that you can also use a different array formula** by "inverting" your COUNTIFS construction:

=STDEV(IF(COUNTIFS(AP10,"<"&AM$9:AM$89,AP11,">="&AM$9:AM$89),AN9:AN89))

which may well be more efficient.

Regards

**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM