+ Reply to Thread
Results 1 to 13 of 13

Excel function to calculate deviation from a fixed value

  1. #1
    Registered User
    Join Date
    06-21-2015
    Location
    Edinburgh
    MS-Off Ver
    2003
    Posts
    6

    Excel function to calculate deviation from a fixed value

    Hi all,

    i'm trying to find a function in excel that will calculate the average deviation/variance of a data set from a fixed value (rather than from the mean like standard deviation etc).

    e.g. if i have a data set (1,-15,5,9,21,-3,12,10,1) i want to determine the average deviation from "zero" rather than the "mean" of the data set.

    can anyone help with this?

    thanks,

    paul.

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Excel function to calculate deviation from a fixed value

    Then by definition you are simply calculating:

    =SQRT(AVERAGE(POWER(YourRange,2)))

    which requires entering as an array formula**.

    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).
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Registered User
    Join Date
    06-21-2015
    Location
    Edinburgh
    MS-Off Ver
    2003
    Posts
    6

    Re: Excel function to calculate deviation from a fixed value

    that's brilliant thanks for the quick reply XOR.

    i tried that and it worked. the only thing is that i am applying this to a range that values will build up and be populated over time. when i use STDEV it ignores "nulls" ie. cells where no value exists yet. however the solution you have provided treats these "nulls" as zeros.

    is there anyway to modify your function to ignore the "nulls"?


    thanks again.


    paul.

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Excel function to calculate deviation from a fixed value

    Sure:

    =SQRT(AVERAGE(IF(ISNUMBER(YourRange),POWER(YourRange,2))))

    Cheers

  5. #5
    Registered User
    Join Date
    06-21-2015
    Location
    Edinburgh
    MS-Off Ver
    2003
    Posts
    6

    Re: Excel function to calculate deviation from a fixed value

    brilliant thanks!

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Excel function to calculate deviation from a fixed value

    You're welcome!

    Cheers!

  7. #7
    Registered User
    Join Date
    06-21-2015
    Location
    Edinburgh
    MS-Off Ver
    2003
    Posts
    6

    Re: Excel function to calculate deviation from a fixed value

    as a matter of interest, what is the reason behind squaring the values before averaging and then square rooting?

    ie. compared to just turning all the values in the range positive and averaging that?

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Excel function to calculate deviation from a fixed value

    Quote Originally Posted by PaulMTC View Post
    compared to just turning all the values in the range positive and averaging that?
    I thought that's what you wanted to do but that formula gives a different result than XOR's formula.

    Both formulas are array entered**:

    =AVERAGE(ABS(A1:A9)) returns 8.55555555555556

    =SQRT(AVERAGE(POWER(A1:A9,2))) returns 10.682280239308

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  9. #9
    Registered User
    Join Date
    06-21-2015
    Location
    Edinburgh
    MS-Off Ver
    2003
    Posts
    6

    Re: Excel function to calculate deviation from a fixed value

    thanks tony. yes i just wanted the average of the distance away from zero - not squaring the distance, then averaging, then square rooting.

    ..... i just wondered if XOR's way had other merits and if so what are they?

  10. #10
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Excel function to calculate deviation from a fixed value

    When you mentioned "deviation" in your original post, I just assumed (perhaps wrongly) that you wanted a variation on standard deviation.

    After all, your argument could be extended to that definition as well, as indeed it clearly has been:

    http://stats.stackexchange.com/quest...standard-devia

    I'll let you decide whether squaring offers you a "better" means of representing "deviation" for your set-up.

    Regards

  11. #11
    Registered User
    Join Date
    06-21-2015
    Location
    Edinburgh
    MS-Off Ver
    2003
    Posts
    6

    Re: Excel function to calculate deviation from a fixed value

    that's a really interesting post you've linked to XOR and answers my question. i don't need to "magnify" values the further they are from zero so "absolute" rather than "squared" differences is better for the situation i'm dealing with. thanks very much again for your time and help (XOR and tony).

  12. #12
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Excel function to calculate deviation from a fixed value

    Sure. Sounds like you're pretty sure what best fits your situation, so that's good.

    And you're welcome!

    Cheers

  13. #13
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Excel function to calculate deviation from a fixed value

    If you need to exclude empty cells...

    =AVERAGE(IF(ISNUMBER(A1:A9),ABS(A1:A9)))

    Or, if the data will always be numbers (no text)...

    =AVERAGE(IF(A1:A9<>"",ABS(A1:A9)))

    Both are still array entered!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Excel 2007 : Calculate percentage with fixed total
    By not_exelerrated in forum Excel General
    Replies: 6
    Last Post: 03-25-2014, 09:44 AM
  2. [SOLVED] Is there any formula to calculate a fixed increase with a fixed price?
    By ec4excel in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-09-2012, 12:15 PM
  3. How to calculate std deviation
    By mdfmcf in forum Excel General
    Replies: 8
    Last Post: 06-16-2012, 11:44 AM
  4. Data with fixed mean and standard deviation
    By Klorgrodan in forum Excel General
    Replies: 2
    Last Post: 02-10-2009, 10:23 AM
  5. VBA Function to calculate Mean and Standard Deviation
    By Divius in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-31-2007, 07:04 AM

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