STDEVIF Function?

rjbinney

Active Member
Joined
Dec 20, 2010
Messages
293
Office Version
  1. 365
Platform
  1. Windows
I know I can do this in Pivot Tables. I want to do this with formulas if possible.

I have a list of products (about 30) (named "SKU") and how long it took to run each (named "Actual") (some ran two or three times, some ran up to 60 times). I need some information about how "in control" the process is. I have a table of the standard runtime for each, and inserted a MATCH column ("Should").

I calculated a column for the delta between "Actual" and "Should" for each run (named "Delta").

So to get the average difference between standard and actual, I can build a table:

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]PRODUCT
[/TD]
[TD]MEAN RUN DIFFERENCE
[/TD]
[/TR]
[TR]
[TD]Product 1
[/TD]
[TD]=SUMIF(Delta, SKU, $A2) / COUNTIF(SKU,$A2)
[/TD]
[/TR]
[TR]
[TD]Product n
[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


I would love to look at the volatility - which means I need to be able to compare the Delta to the Mean. Is there a clever formula that will tell Excel to ONLY consider based on, say, SKU criteria.

It's that last bit - basing it on criteria that's important. Because in addition to SKUs, I also have columns (and need to cut data) based on corresponding equipment, region produced, end product, customer, etc. So it's super-easy to build tables to calculate the mean (based on above formula). It's the standard deviation I'm stuck on!

Again, I know I can pull it together with Pivot Tables, but I have my reasons for not using 'em.

Thanks,

Thanks,
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Something like this?
This is an array formula and must be entered with CTRL-SHIFT-ENTER.
Excel Workbook
ABCDEFG
1ProductsRun TimeShouldDeltaProductsStd
2Product12:332:050:28Product10:43
3Product24:154:200:05Product20:21
4Product13:222:051:17
5Product11:552:050:10
6Product24:004:200:20
7Product24:454:200:25
8Product12:052:050:00
9Product24:434:200:23
10Product24:064:200:14
11Product12:302:050:25
Sheet
 
Upvote 0
I'll give it a try, thanks. I always forget that arrays are a "thing".
 
Upvote 0
There is an error in the formula I gave you.In the variance formula the denominator should be "sample size -1" (N-1). When I was checking the formula I hard coded in a 4 which works in the example, but won't fit your data. You will need to change the formula to (also change ranges to match your data).

Code:
[TABLE="width: 527"]
<colgroup><col width="527"></colgroup><tbody>[TR]
   [TD="width: 527"]SQRT(SUM(IF($A$2:$A$11=$F2,($D$2:$D$11)^2))/[COLOR=#ff0000](COUNTIF($A$2:$A$11,$F2)-1)[/COLOR])
[/TD]
 [/TR]
</tbody>[/TABLE]
 
Upvote 0
I know it's been a while, but I'm back on this. And I'm missing something.

I always have trouble working with "time" - so for now, let's take your data but convert it to "whole numbers" in elapsed seconds:
[TABLE="width: 214"]
<tbody>[TR]
[TD][/TD]
[TD]Actual[/TD]
[TD]Should[/TD]
[TD]Delta[/TD]
[/TR]
[TR]
[TD]Product1[/TD]
[TD="align: right"]153[/TD]
[TD="align: right"]125[/TD]
[TD="align: right"]28[/TD]
[/TR]
[TR]
[TD]Product2[/TD]
[TD="align: right"]255[/TD]
[TD="align: right"]260[/TD]
[TD="align: right"]5[/TD]
[/TR]
[TR]
[TD]Product1[/TD]
[TD="align: right"]202[/TD]
[TD="align: right"]125[/TD]
[TD="align: right"]77[/TD]
[/TR]
[TR]
[TD]Product1[/TD]
[TD="align: right"]115[/TD]
[TD="align: right"]125[/TD]
[TD="align: right"]10[/TD]
[/TR]
[TR]
[TD]Product2[/TD]
[TD="align: right"]240[/TD]
[TD="align: right"]260[/TD]
[TD="align: right"]20[/TD]
[/TR]
[TR]
[TD]Product2[/TD]
[TD="align: right"]285[/TD]
[TD="align: right"]260[/TD]
[TD="align: right"]25[/TD]
[/TR]
[TR]
[TD]Product1[/TD]
[TD="align: right"]125[/TD]
[TD="align: right"]125[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD]Product2[/TD]
[TD="align: right"]283[/TD]
[TD="align: right"]260[/TD]
[TD="align: right"]23[/TD]
[/TR]
[TR]
[TD]Product2[/TD]
[TD="align: right"]246[/TD]
[TD="align: right"]260[/TD]
[TD="align: right"]14[/TD]
[/TR]
[TR]
[TD]Product1[/TD]
[TD="align: right"]150[/TD]
[TD="align: right"]125[/TD]
[TD="align: right"]25[/TD]
[/TR]
</tbody>[/TABLE]

If I use your array formula, I get this for results:
Product1=43.12
Product2=21.07
Code:
{=SQRT(SUM(IF(SKU=$A14,(Delta)^2))/(COUNTIF(SKU,$A14)-1))}

But if I just sort out Product1 and run a =STDEV (or STDEVA or STDEV.P) I get completely different results!
Product1 STDEV=29.66, STDEV.P=26.53
Product2 STDEV=8.08 , STDEV.P=7.23

(And if I grunt the numbers by hand, I get the STDEV.P result).

#SuperConfused !
 
Upvote 0
Why not just use the STDEV.P formula as an array formula?

=STDEV.P(IF(SKU=A14,Delta))

with Control+Shift+Enter.
 
Upvote 0
'Coz I didn't know that would work! (Guess who needs to read up on how arrays work!)

Thanks!
 
Upvote 0
OK, this opened up a world of possibilities for me.

=AVERAGE(IF(SKU="Product2",B$12:B$1510))

Has been awesome - cutting averages based on SKU.



Now, what if I want to cut on TWO variables? Say, SKU and warehouse ("WHS")?

I tried
=AVERAGE(IF(AND(SKU="Product2",Collector=5),B$12:B$1510)) and got nothing.(Literally, "0").
 
Upvote 0
You usually can't use AND in array formulas, since it works on the entire nX2 array, not just the 1X2 row. Instead you need to use Boolean operators. * (times) is the equivalent of AND, and + (plus) is the equivalent of OR. So your AVERAGE formula should look something like:

=AVERAGE(IF((SKU="Product2")*(Collector=5),B$12:B$1510))

Alternately, you can string additional IF functions:

=AVERAGE(IF(SKU="Product2",IF(Collector=5,B$12:B$1510)))

both with Control+Shift+Enter.
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,310
Members
452,634
Latest member
cpostell

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