+ Reply to Thread
Results 1 to 7 of 7

Use min and Max excluding top and bottom values

Hybrid View

  1. #1
    Valued Forum Contributor saravnepali's Avatar
    Join Date
    01-14-2019
    Location
    Sydney Australia
    MS-Off Ver
    2010
    Posts
    447

    Use min and Max excluding top and bottom values

    I have a table with several percentage values corresponding to concept, strategic etc.

    Now, the user can select a value from a table.

    After this, I want to show min,max and average of the filtered value (NOT ALL FILTERED VALUE BUT VALUE FROM MIDDLE, EXCLUDING TOP 25% and lower 25%)

    I tried to do it with filter (as shown) in attached, and have shown sample data for two typical cases.

    I was able to use trimmean to get as an array to get the average but NOT the maximum and minimum.

    Can it be done using any formula sequence or array formula, possibly without VBA for minimum and maximum too

    Thanks in advance.
    Attached Files Attached Files
    Last edited by saravnepali; 08-19-2020 at 05:30 AM.
    If you think someone helped you, click on the "* Add Reputation" as a way to say thank you.

    If your problem is solved, go to Thread Tools and select Mark This Thread Solved

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Use min and Max excluding top and bottom values

    Make a table of your data.

    below 0,00%
    min 14,00% Yes
    max 20,00% yes
    above 20,01%
    D2 =VLOOKUP($C10,$J$1:$K$14,2,1)

    See the attached file.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,743

    Re: Use min and Max excluding top and bottom values

    I think it shouldn't goes this way. Cut off 25% of bottom results and 25% of top results as result not a result value. So you can't set criteria 14% and 20% to cut off (as I understand).
    I've prepared something in VBA like this:

    Put into standard module:

    Sub MyCalc()
    Dim cell As Range
    Dim temp() As Variant
    Dim MyVal2() As Variant
    Dim i, j As Long
    i = 0
    j = 0
    For Each cell In [B4:B150]
        If cell.Value = [D1].Value Then
            ReDim Preserve temp(i)
            temp(i) = cell.Offset(0, 1).Value
            i = i + 1
        End If
    Next cell
    For i = ((UBound(temp) + 1) * 0.25) To ((UBound(temp) + 1) * 0.75 - 1)
            ReDim Preserve MyVal2(j)
            MyVal2(j) = temp(i)
            j = j + 1
    Next i
    [D2].Value = Application.WorksheetFunction.Average(MyVal2)
    [E2].Value = Application.WorksheetFunction.Min(MyVal2)
    [F2].Value = Application.WorksheetFunction.Max(MyVal2)
    End Sub
    and into code of Sheet1 or Sheet2 (check attached file):

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, [D1]) Is Nothing Then
        Range("$A$3:$C$121").AutoFilter Field:=2, Criteria1:=[D1].Value
        Call MyCalc
    End If
    End Sub
    imho works correctly.
    Last edited by KOKOSEK; 08-19-2020 at 09:57 AM.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  4. #4
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Use min and Max excluding top and bottom values

    Please try at
    E4
    =AVERAGEIFS(C4:C121,B4:B121,D1,C4:C121,">="&F2,C4:C121,"<="&G2)

    F4
    =QUARTILE.INC(IF(B4:B121=D1,C4:C121),1)

    G4
    =QUARTILE.INC(IF(B4:B121=D1,C4:C121),3)

    Ctrl+Shift+Enter for E4 and G4
    Attached Files Attached Files

  5. #5
    Valued Forum Contributor saravnepali's Avatar
    Join Date
    01-14-2019
    Location
    Sydney Australia
    MS-Off Ver
    2010
    Posts
    447

    Re: Use min and Max excluding top and bottom values

    Thanks all

    I will check it and will let you know.

  6. #6
    Valued Forum Contributor saravnepali's Avatar
    Join Date
    01-14-2019
    Location
    Sydney Australia
    MS-Off Ver
    2010
    Posts
    447

    Re: Use min and Max excluding top and bottom values

    Thanks all.

    But, the solutions didn't solve the problem to get the desired result.

    To make things clear, I have revised the data. Now the data against post tender contains 1% to 10%

    I want to trim off 40% of total data (out of 10), so 2 from the top and 2 from the bottom of the values.
    So, if 2 extreme data are taken out from top & bottom it gives values ranging from 3% to 8%.

    Average of this range is 6%, minimum is 3% and max 8%. Trim mean does gives the average, but need for a formula to give min & max.

    Alternatively, I managed to get formulas on rows to get the desired outcome (might not be the best way to do it), but would prefer a single formula to get it. (Possibly an array formula) The attached sheet has cell highlighted in yellow to give the result as a formula - need to make that formula to an array formula.
    Attached Files Attached Files
    Last edited by saravnepali; 08-23-2020 at 11:24 PM.

  7. #7
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Use min and Max excluding top and bottom values

    This is trim 50% in Post #1
    Quote Originally Posted by saravnepali View Post
    EXCLUDING TOP 25% and lower 25%)
    Post #6
    Quote Originally Posted by saravnepali View Post
    I want to trim off 40%

    Last try
    Min
    =PERCENTILE.INC(IF(B4:B15=D1,C4:C15),0.2)
    or
    =INDEX(C4:C15,MATCH(1,($C$4:$C$15>=PERCENTILE.INC(IF(B4:B15=D1,C4:C15),0.2))*($B$4:$B$15=D1),))

    Max
    =PERCENTILE.INC(IF(B4:B15=D1,C4:C15),0.8)
    or
    =LOOKUP(2,1/(C4:C15<=PERCENTILE.INC(IF(B4:B15=D1,C4:C15),0.8))/(B4:B15=D1),C4:C15)
    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] Take average of a range -- excluding top 1/3 and bottom 1/3 and zero values
    By saravnepali in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-01-2020, 06:29 PM
  2. [SOLVED] Count duplicate text values in columns whilst ignoring/excluding certain values
    By adamwestwell in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-02-2017, 05:34 AM
  3. [SOLVED] Sum values based on row name, write values to bottom of sheet
    By YOO629 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-14-2015, 01:30 PM
  4. Replies: 1
    Last Post: 03-03-2014, 11:06 AM
  5. [SOLVED] Average excluding percentiles (top/bottom nth percent)
    By ker9 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-13-2014, 04:34 PM
  6. Formula for Conditional Formatting Bottom 5 excluding 0's
    By FlyinIron406 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-10-2013, 02:23 AM
  7. [SOLVED] 1 Cell to Formulate Cumulative Total Excluding Top & Bottom 10%
    By benishiryo in forum Excel General
    Replies: 6
    Last Post: 10-05-2012, 09:18 PM

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