+ Reply to Thread
Results 1 to 23 of 23

Large Function with Repeated Values

  1. #1
    Registered User
    Join Date
    07-15-2010
    Location
    California, United States
    MS-Off Ver
    Excel 2010
    Posts
    45

    Large Function with Repeated Values

    I have a column with number values that are repeated:

    ex.
    1
    2
    3
    3
    3
    4
    4
    5
    5

    I have a problem with the large function when I tried to find the second largest value in the column because when I type =large(range,2) the result will be 5 instead of 4.
    I have to type =large(range,3) to get my desired value of 4.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,352

    Re: Large Function with Repeated Values

    This is how the Large function works. It ranks the numbers and picks the nth largest in the rank. There are sumif and sumproduct formulas that seem to work. What you really want is a unique list of the values and then do a large of those.

    In 2010 excel there is a function on the Data Tab called "Remove Duplicates". You can use this to get a unique list. I'd copy the column with all the dups to a blank range and remove duplicates from this copy (you don't want to mess up your data).. Then do a Large on this range to find the nth unique value.

  3. #3
    Registered User
    Join Date
    07-15-2010
    Location
    California, United States
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Large Function with Repeated Values

    Is there a way to do this with an array formula then?

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,352

    Re: Large Function with Repeated Values

    I believe there is but my brain is too small to deal with CSE (control-shift-enter) array formulas. See another forum for their discussion on this topic at: http://www.mrexcel.com/forum/showthread.php?t=356222

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Large Function with Repeated Values

    =large(a1:a9, countif(a1:a9, max(a1:a9)) + 1)
    Entia non sunt multiplicanda sine necessitate

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

    Re: Large Function with Repeated Values

    If you have numbers in A1:A100 you can get a list of unique numbers in descending order like this:

    In C1

    =MAX(A1:A100)

    Then in C2

    =MAX(IF(ISNA(MATCH(A1:A100,C$1:C1,0)),A1:A100))

    confirmed with CTRL+SHIFT+ENTER and copied down the column........or do you want a single formula to find the "nth" largest value (ignoring duplicates)?
    Audere est facere

  7. #7
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,352

    Re: Large Function with Repeated Values

    Hi shg
    I understand your formula. How would you fix this for third largest value with repeats?

    Hi daddylonglegs too
    Can I do all CSE formulas using the multiple criteria formulas new to 2007 and 2010. Or put another way - are CSE (Array Formulas or Super Formulas/Bill Jelen) needed for Excel version after 2003?

    I'm wondering how hard I have to work to understand CSEs, or if they might just go away with a few more versions of Excel.

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

    Re: Large Function with Repeated Values

    I doubt if "array formulas" are going away any time soon. There's still no MAXIF function (so you can't do the above without CSE, even in Excel 2010) and there are many other circumstances where you might need to use one.

    Of course AVERAGEIFS function eliminates some need and AGGREGATE function in 2010 lets you sum and average (and other things) while ignoring errors so that will obviate the need for another category of CSE....

    ....but I reckon I suggest at least one a day, probably more, here or somewhere else.....

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

    Re: Large Function with Repeated Values

    For 3rd largest value you could extend the logic of shg's suggestion, i.e.

    =LARGE(A1:A100,COUNTIF(A1:A100,">="&LARGE(A1:A100, COUNTIF(A1:A100, MAX(A1:A100)) + 1))+1)

    assuming data in A1:A100

    but that formula will then get progressively larger for 4th, 5th largest etc.

    One way to get the nth largest value would be like this (array entered)

    =LARGE(IF(COUNTIF(A$1:A$100,ROW(INDIRECT(MIN(A$1:A$100)&":"&MAX(A$1:A$100)))),ROW(INDIRECT(MIN(A$1:A$100)&":"&MAX(A$1:A$100)))),C1)

    where C1 contains n

    assumes that A1:A100 contains positive integers < 65536

  10. #10
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,352

    Re: Large Function with Repeated Values

    OK -
    I guess I'll crack my Excel help file and learn Array Formulas.

    Last question. I suggested to create a column of unique values using copy->paste values. Then do an Excel delete duplicates. I'm sure this would work as an intermediate step and then the Large (array, n) would be easy for any n. Why are intermediate steps not appropriate for most users? (Only based on my limited experience on this site.)

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

    Re: Large Function with Repeated Values

    Marvin,

    Your suggestion sounds like a great idea to me. It's often more efficient to use helper columns or other techniques, especially so in this case where a single cell formula can get quite complex (and very inefficient).

    In general I'm not sure that the users here are against intermediate steps. Common sense dictates that one should use the most appropriate method in each scenario, whether that be pivot tables, VBA, single cell formulas or helper columns.....but of course some users might be biased in favour of one particular approach, often the one they understand the best.

    Of course I'm a connoisseur and purveyor of "complex" formulas......so my suggestions tend to be biased in that direction......but I know it's not always the best way.

    regards, daddylonglegs

  12. #12
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,352

    Re: Large Function with Repeated Values

    daddylonglegs,

    Thanks for the confirmation that intermediate steps may be used in a solution.

    BTW - I now understand much more about CSE's and even understand why a double unary is prefered by many. I didn't know the term "double unary" a few hours ago.

    Being the guru of complex, do you spend much time in the Evaluate Formula dialog? Do Array Formulas work with in the dialog?

    also - thanks for the honest survey of "what's best".

  13. #13
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Large Function with Repeated Values

    In another vain attempt to understand formula better, I cobbled this together using helper columns.

    In B2 (Helper Column)
    Please Login or Register  to view this content.
    Drag/Fill Down

    In C2 (Helper Column)
    Please Login or Register  to view this content.
    Drag/Fill Down

    In the demo workbook enter your required ranking in E2 the result is given in D2 and highlighted in the table.
    The helper columns can be toggled with the +/- grouping button(s).

    Hope this helps

    [EDIT]
    Data must be continuous, i.e no blanks, zeros are okay.
    Attached Files Attached Files
    Last edited by Marcol; 09-04-2010 at 08:35 AM.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  14. #14
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,352

    Re: Large Function with Repeated Values

    Hi Marcol,

    Thanks for teaching me something. I loved that you used intermediate steps (in columns) and then hid them. I also liked the Conditional Formatting input area that showed which number was being selected.

    I tried to "Formula Evaluate" your formula about 4 times and it made my head swim, so I tried to solve the problem on my own (being an independent kind of guy).

    I then created my own intermediate column formulas (that I could understand (they're short)) and did the problem again. See attached::

    I'm now pondering dislexia, and if how we look at a problem. Does it become clearer and easier to solve if viewed in a certain way? Also, can you explain your solution to others who can then also get the answer on their own. The teacher in me comes out often!

    Thanks for showing me a different way - I hope my example show you another.

    I used to teach and this story was one of my favorites - It applies here...
    Attached Files Attached Files

  15. #15
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Large Function with Repeated Values

    I often build a formula in stages to check for potential errors, a bit like in maths problems (Let D2 = LARGE(A:A,ROW()-1)).
    I'm just a simple engineer, no formula wizard!

    Often this method points to a better way once all the factors are laid out in front of you.

    By subsituting the Vaules D1 & D2 in Column E

    in Row 2
    Please Login or Register  to view this content.
    will return #NUM! in Row 2 thereafter it is okay.

    This is because Row()-2 = 0 in row 2
    to correct this
    Please Login or Register  to view this content.

    Because I chose a slightly different approach, your formula extended is shorter.
    Please Login or Register  to view this content.

    This will cut out one helper column at least!

    This is not meant to contradict the people who CAN BUILD supercharged formulae, just a very basic approach to a problem.

    There are many ways to solve problems.

    It's a bit like the old Scots adage
    "There are no bad whiskies, just some are better than others.".....

    On that note, a beer beacons!... ...

    Slainte
    Alistair
    Attached Files Attached Files
    Last edited by Marcol; 09-04-2010 at 01:36 PM.

  16. #16
    Registered User
    Join Date
    02-05-2013
    Location
    San Francisco
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Large Function with Repeated Values

    Hi,

    I have a list of six loans and some contain duplicate amounts. Column A is the Loan Name and Column B is the amount of the loan:

    Loan XYZ, $300
    Loan ABC, $300
    Loan MNO, $200
    Loan PQR, $250
    Loan HIJ, $250
    Loan 123, $100

    How would I display the top five loans with its corresponding loan amount, regardless of the duplicate values, with an array formula? Would I have to assign, in Column C, a unique value for each row?

    I used the following formulas to pull the loan amounts:
    =LARGE($B$1:$B$6,COUNTIF($B$1:$B$6,MAX($B$1:$B$6))+0)
    =LARGE($B$1:$B$6,COUNTIF($B$1:$B$6,MAX($B$1:$B$6))+1)
    =LARGE($B$1:$B$6,COUNTIF($B$1:$B$6,MAX($B$1:$B$6))+2)
    =LARGE($B$1:$B$6,COUNTIF($B$1:$B$6,MAX($B$1:$B$6))+3)
    =LARGE($B$1:$B$6,COUNTIF($B$1:$B$6,MAX($B$1:$B$6))+4)

    I used the following formula to pull the loan name:
    =INDEX($A$1:$A$6,MATCH([Dollar Amount of Loan],$B$1:$B$6,0))

    The result I keep getting, which I don't want, is this:
    Loan XYZ, $300
    Loan XYZ, $300
    Loan PQR, $250
    Loan PQR, $250
    Loan MNO, $200

    My intended result would look like this:
    Loan XYZ, $300
    Loan ABC, $300
    Loan PQR, $250
    Loan HIJ, $250
    Loan MNO, $200

    I hope this is clear and apologize if it's confusing. Any help would be so appreciated.


    Thanks,
    Last edited by triv; 02-05-2013 at 11:26 PM.

  17. #17
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,366

    Re: Large Function with Repeated Values

    Welcome to the forum Triv. You can create your own thread.

    When you click "Excel General" subforum you'll notice the---> " + POST NEW THREAD" button...put the above and name it that is appropriate to your needs.




    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  18. #18
    Registered User
    Join Date
    02-05-2013
    Location
    San Francisco
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Large Function with Repeated Values

    Thank you, vlady. I will keep that in mind. I didnt want to post a new thread and inundate other users with a similar type of post but will start my own thread/question next time.

    Thank you, Tony. I will try your formula and let you know how it goes.

    Thank you both for the quick responses.

  19. #19
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,366

    Re: Large Function with Repeated Values

    @ triv, if possible, can you post your query in the new thread, then also put the solution you've got from Tony so others would also benefit from the solution provided to you.
    you can then put a link to the new one in your post above so Tony and other members could follow the thread. And if other problems appear you can continue the discussions there.

    Regards,
    Vladimir

  20. #20
    Registered User
    Join Date
    03-16-2013
    Location
    TX
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Large Function with Repeated Values

    Partial solution for posterity:

    Functions Used (parameters described in terms of current context)::
    • Frequency: (array of numbers - Range, number to test- Double) , returns the number of elements in the array that are
      less than or equal to "number to test".
    • Count: (array of numbers) , returns the length of the array, or how many elements the array contains.
    • Large: (array of numbers, rank to be returned) , returns the value that is the rank indicated in the parameters (i.e. the "kth" value)

    Assumptions ::
    • Your list of numbers spans from A1 to A100
    • You are returning the list in B1 onward
    • The max value (rank 1) is listed in B1
    • The delta between your array elements is greater than .0000001 (can be adjusted easily if delta is less)
    • This is a recursive solution, so all ranks less than k need to be listed somewhere in your workbook. If you are looking for the 5th largest, for example, the 1st-4th need to be listed somewhere. (AutoFill makes this easy if they are consecutive)

    Equation (entered in cell B2)::
    =IFERROR(LARGE(A$1:A$100,COUNT(A$1:A$100)-FREQUENCY(A$1:A$100,A1-.00000001)+1),"")
    Please Login or Register  to view this content.
    This will return the 2nd largest item in the list ignoring duplicates. To return k>2 onward, AutoFill (drag down) the equation and the
    below cells will contain the k=n largest value.

    Summary ::
    These steps return unduplicated decreasing list with the cell n containing the nth ranked value.

  21. #21
    Registered User
    Join Date
    09-27-2015
    Location
    Dubai, UAE
    MS-Off Ver
    2010
    Posts
    4

    Re: Large Function with Repeated Values

    Hi Guys,

    I need some help here...

    I don't have much knowledge of EXCEL formulas and I prepared the attached sheet in which I have manually entered the information I require.

    The original file I have has over 1500 entries that I need to check & match etc. which will take forever, hope you guys can help with some formal that could make life easier. Thanks.
    Attached Files Attached Files

  22. #22
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Large Function with Repeated Values

    Hi Rachandsouza.

    Please take a moment to read through the rules that you agreed to when you joined the forum.

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    As your post is a breach of forum rules, we are not able to answer your question here.

  23. #23
    Registered User
    Join Date
    09-27-2015
    Location
    Dubai, UAE
    MS-Off Ver
    2010
    Posts
    4

    Re: Large Function with Repeated Values

    Noted Jason...I've posted a new thread...http://www.excelforum.com/excel-form...ml#post4201029

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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