+ Reply to Thread
Results 1 to 6 of 6

Excluding Cells from Standard Deviation Formula

  1. #1
    Registered User
    Join Date
    12-17-2012
    Location
    Ohio
    MS-Off Ver
    Excel 2010
    Posts
    6

    Excluding Cells from Standard Deviation Formula

    Hey guys,

    I have a question regarding the standard deviation formula in excel. I have a column for which I want to find the standard deviation. Every value for this column should be between 0 and 1000 (the column contains lag days). However, when this data is imported into excel, a very limited amount of the information is imported as either a negative number or a very high number, such as 45000.

    So, my question is, is there a way to write a standard deviation formula for one column that will exclude numbers less than 0 and greater than 1000 from the calculation?

    Thanks,
    Marty

  2. #2
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Excluding Cells from Standard Deviation Formula

    Try this array formula

    Please Login or Register  to view this content.
    Confirm with Ctrl+Shift+Enter and not just Enter
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  3. #3
    Registered User
    Join Date
    12-17-2012
    Location
    Ohio
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Excluding Cells from Standard Deviation Formula

    I can get an answer using this formula, but it obviously is not the correct answer. I tried two variations:

    =STDEV(IF((B:B<1000)*(B:B>=0),B:B))
    and
    =STDEV(IF((B:B<1000)*(B:B>0),B:B)) (no equal sign)

    Using the first option is giving me values that are much too small to be correct. The data set is not that tight, but I am getting sub .1 deviations. Using the second formula, without the equal sign, is giving me deviations that seem much too large. For instance, I am getting a deviation of 9.15 for a dataset with an average of 3.24. I do not have many numbers above, say, 20 so I know by looking that stdev number can't be right.

    I will have to calculate the stdev manually for one of my columns to be sure of the correct answer when I find the right formula, but I am 99.9% sure the results I got with these formulas did not work. This is, however, the first formula I have found that hasn't given me an error message when attempting to enter the formula.

    Thanks,
    Marty

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,698

    Re: Excluding Cells from Standard Deviation Formula

    If you refer to the whole column then blank cells will be treated as zeroes in that first formula, hence why the values are too low. Either only use the populated range in the formula or specifically exclude blanks like this

    =STDEV(IF((B:B<1000)*(B:B>=0)*(B:B<>""),B:B))

    Did you confirm with CTRL+SHIFT+ENTER - if done correctly you get curly braces like { and } around the formula
    Audere est facere

  5. #5
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Excluding Cells from Standard Deviation Formula

    Referencing the entire column would mean that blank cells would be treated as 'zero', hence your first formula with the ">=0" will yield wrong results. having said that, the second formula with the "<0" should give correct results.

    Make sure you confirm with Ctrl+Shift+Enter, else upload a sample worksheet if you still run into issues

  6. #6
    Registered User
    Join Date
    12-17-2012
    Location
    Ohio
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Excluding Cells from Standard Deviation Formula

    It looks like that adjustment is working for me daddylonglegs. I will evaluate further tomorrow, but the numbers look correct. Thanks for your post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1