+ Reply to Thread
Results 1 to 6 of 6

imposing a limit on which values to use in averaging

Hybrid View

  1. #1
    Registered User
    Join Date
    03-25-2016
    Location
    lodi ca
    MS-Off Ver
    2010
    Posts
    3

    imposing a limit on which values to use in averaging

    I have a data set, I want an average, but I want it to throw out any value that is greater than 30% different and average the rest

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: imposing a limit on which values to use in averaging

    30% less than the max?

    30% More than the least

    30% less than the next smallest

    30% bigger than the next biggest

    30% less than the median

    30% greater than the median
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    03-25-2016
    Location
    lodi ca
    MS-Off Ver
    2010
    Posts
    3

    Re: imposing a limit on which values to use in averaging

    thanks, so I am looking for it to throw out any value that is 30% or more different than the average of the high and low value.

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: imposing a limit on which values to use in averaging

    I assume your Data set will be in a contiguous range.

    Probbably in one column.

  5. #5
    Registered User
    Join Date
    03-25-2016
    Location
    lodi ca
    MS-Off Ver
    2010
    Posts
    3

    Re: imposing a limit on which values to use in averaging

    yes and typically there are only 3 values sometimes 4

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: imposing a limit on which values to use in averaging

    Ok I have two solutions for you.

    The following User Defined Function needs two inputs.

    A range and a variance.

    In my example the range is G3:G10 and the variance is 30%

    Entering MyAverage(G3:G10,30) amywhere on the spreadsheet will return 8.75

    I checked this using a helper column H3:H10 to check if the number in column G is in range

    Then a Sum of the values in column H divided by a countif of the numbers in column H gave a result of 8.75


    
    Function MyAverage(R As Range, M As Integer)
    MyArray = Application.Transpose(R.Value)
    Median = (Application.Min(R.Value) + Application.Max(R.Value)) / 2
    Count = 0
    Sum = 0
    
    For Count = 1 To UBound(MyArray)
    
    If MyArray(Count) >= Median * (100 - M) / 100 And MyArray(Count) <= Median * (100 + M) / 100 Then
    Items = Items + 1
    Sum = Sum + MyArray(Count)
    End If
    
    Next
    MyAverage = Sum / Items
    
    End Function
    Attached Files Attached Files

+ 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. [SOLVED] Averaging Data values, but only the values on WORKDAYS (no weekend/holidays)
    By Alphabex in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 12-02-2015, 06:02 PM
  2. averaging values if a certain name is next to it
    By cobra0798 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-08-2014, 04:07 PM
  3. Replies: 12
    Last Post: 09-04-2013, 03:55 PM
  4. Excel 2010's pivot tables insist on imposing basic math on my values.
    By cdoggown in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 01-29-2013, 01:36 AM
  5. Averaging values based on seperate column values
    By beng404 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-16-2011, 10:07 AM
  6. Averaging every set of four values
    By Sharief in forum Excel General
    Replies: 6
    Last Post: 12-05-2009, 10:27 AM
  7. Replies: 0
    Last Post: 08-29-2005, 07:45 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