+ Reply to Thread
Results 1 to 29 of 29

Alternative to using an array formula for {=LARGE(IF(... function

  1. #1
    Registered User
    Join Date
    05-29-2014
    Location
    West Midlands, England
    MS-Off Ver
    2011 for Mac
    Posts
    5

    Alternative to using an array formula for {=LARGE(IF(... function

    I'm (very) new to excel so bare with me.

    I have an excel spreadsheet to log incoming samples from different companies (Sample ID, Company,..., Date received,...etc.).

    A second sheet in the workbook has a list of every company that has ever sent in a sample (basically, a database with their contact details), in alphabetical order. I have a column in this sheet called 'Last Active' to tell me the date for which the last sample was sent in for each company.

    My formula for this is:
    {=LARGE(IF('Sheet 1'!C:C=Sheet 2!A2,'Sheet 1'!I:I),1)}

    However, this array formula is calculating through around 3500 rows in Sheet 1, which I think is what is causing the huge delay when the sheet calculates. I've had to switch it to manual because it was freezing every time I changed anything in the workbook. Ideally, I'd like for it to be calculating automatically.

    Is there a way to replace the array formula to something which isn't so intensive in terms of calculating? Perhaps breaking it down into several columns and hiding the unnecessary ones?

    Any help would be appreciated!

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Alternative to using an array formula for {=LARGE(IF(... function

    Welcome to the board.

    Quote Originally Posted by Rabiah View Post
    {=LARGE(IF('Sheet 1'!C:C=Sheet 2!A2,'Sheet 1'!I:I),1)}

    However, this array formula is calculating through around 3500 rows in Sheet 1
    Actually, that's not quite correct.
    It's calculating through ALL rows in the sheet, 65536 (or 1048576 in XL2007+)


    Restricting your formula to the actual used range will significantly improve the performance.
    To accomodate adding data later, I generally recommend adding 10% to the expected number of rows.
    If you have around 3500 rows, then 3500 * 10% = 350
    So do 3850 (or just round up to 4000)

    {=LARGE(IF('Sheet 1'!C$1:C$4000=Sheet 2!A2,'Sheet 1'!I$1:I$4000),1)}

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Alternative to using an array formula for {=LARGE(IF(... function

    You can speed it up a lot by reducing it to your 3500 rows instead of the entire column

    {=LARGE(IF('Sheet 1'!C2:C3600=Sheet 2!A2,'Sheet 1'!I2:I3600),1)}

    Does that speed things up?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  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: Alternative to using an array formula for {=LARGE(IF(... function

    Hi,

    For a start, you should never use entire column references in array formulas - that formula will calculate over all one-million-plus rows, whether beyond your last non-empty cell or not.

    Either change the references to a suitable upper limit, e.g. 4000 (you mentioned 3500) or, if you are using Excel 2010 or later, let us know (you don't give your version in your profile) and there's a non-array version which may be slightly more efficient.

    (We can add an INDEX to that current formula to make it technically non-array (i.e. doesn't require CSE), though this doesn't improve things as much as some imagine.)

    Regards
    Click * below if this answer helped

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

  5. #5
    Registered User
    Join Date
    05-29-2014
    Location
    West Midlands, England
    MS-Off Ver
    2011 for Mac
    Posts
    5

    Re: Alternative to using an array formula for {=LARGE(IF(... function

    I'm using Excel 2011 for Mac.

    Sorry, I didn't mention that I am constantly updating the first sheet as companies send in more samples which is why there is no limit set.

    So it would be better to set an upper limit and just update this limit as and when required?

    Many thanks!

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Alternative to using an array formula for {=LARGE(IF(... function

    Look into using Dynamic Named Ranges

    http://www.contextures.com/xlNames01.html


    Or, make your formula extend a little beyond the actual data set, as suggested.

    Then, when you ADD data, use INSERT instead of Paste.
    The formula will automatically adjust

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

    Re: Alternative to using an array formula for {=LARGE(IF(... function

    Another option is to use dynamic ranges (ranges that automatically expand when new data is added).

    What version of Excel are you using?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  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: Alternative to using an array formula for {=LARGE(IF(... function

    I'm using Excel 2011 for Mac.
    Assuming the ribbon is the same as a pc version...

    Goto the Formulas tab>Define Name
    Name: Company
    Refers to:

    ='Sheet 1'!$C$2:INDEX('Sheet 1'!$C:$C,MATCH("zzzzz",'Sheet 1'!$C:$C))

    Name: Values
    Refers to:

    ='Sheet 1'!$I$2:INDEX('Sheet 1'!$I:$I,MATCH("zzzzz",'Sheet 1'!$C:$C))

    Then, your array formula becomes:

    =LARGE(IF(Company='Sheet 2'!A2,Values),1)

    Or:

    =MAX(IF(Company='Sheet 2'!A2,Values))

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

    Re: Alternative to using an array formula for {=LARGE(IF(... function

    Quote Originally Posted by Tony Valko View Post

    ='Sheet 1'!$C$2:INDEX('Sheet 1'!$C:$C,MATCH("zzzzz",'Sheet 1'!$C:$C))
    Five "z"s, eh? Interestingly random choice! (And slightly less tiresome and automatic than 255 anyway.)

    Still, would love it if the OP had a Company listed: "zzzzzz Beds Inc"!!

    Regards

  10. #10
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Alternative to using an array formula for {=LARGE(IF(... function

    Quote Originally Posted by XOR LX View Post
    Still, would love it if the OP had a Company listed: "zzzzzz Beds Inc"!!
    Interesting thought,

    Might be better to use the numbers in column I to find the last row..

    ='Sheet 1'!$C$2:INDEX('Sheet 1'!$C:$C,MATCH(9.99999999999999E+307,'Sheet 1'!$I:$I))
    and
    ='Sheet 1'!$I$2:INDEX('Sheet 1'!$I:$I,MATCH(9.99999999999999E+307,'Sheet 1'!$I:$I))

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

    Re: Alternative to using an array formula for {=LARGE(IF(... function

    Quote Originally Posted by XOR LX View Post
    Five "z"s, eh? Interestingly random choice! (And slightly less tiresome and automatic than 255 anyway.)

    Still, would love it if the OP had a Company listed: "zzzzzz Beds Inc"!!

    Regards
    Pedantic makes my skin crawl!

    Think outside the box. Free yourself from the "herd"!

    If I have a list that contains either Y or N (for Yes and No) why on earth would I want to use a lookup value of:

    REPT("z",255)

    When something as simple as "z" will do?

    Same principal applies to the last number in a list.

    A bazillion 9's or 100?

  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: Alternative to using an array formula for {=LARGE(IF(... function

    Quote Originally Posted by Tony Valko View Post
    Pedantic makes my skin crawl!

    Think outside the box. Free yourself from the "herd"!

    If I have a list that contains either Y or N (for Yes and No) why on earth would I want to use a lookup value of:

    REPT("z",255)

    When something as simple as "z" will do?

    Same principal applies to the last number in a list.

    A bazillion 9's or 100?
    You misinterpreted my post - I was actually on your side!!

  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: Alternative to using an array formula for {=LARGE(IF(... function

    Quote Originally Posted by XOR LX View Post
    You misinterpreted my post - I was actually on your side!!
    Yes, I know!

    The rant was for the benefit of others that may have an open mind.

  14. #14
    Registered User
    Join Date
    05-29-2014
    Location
    West Midlands, England
    MS-Off Ver
    2011 for Mac
    Posts
    5

    Re: Alternative to using an array formula for {=LARGE(IF(... function

    Thanks for the suggestions.

    I tried the dynamic ranges but it still takes around 10 seconds to calculate. Could that be because I'm referencing entire columns for other formulas on the sheet?

    E.g. This formula is to total the number of uninvoiced samples from each company:

    =SUM(COUNTIFS('Sheet 1'!C:C,A8,'Sheet 1'!L:L,"N",'Sheet 1'!H:H,"*"&"T"&"*"))

    Would it be better to name columns L and H too?

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

    Re: Alternative to using an array formula for {=LARGE(IF(... function

    Quote Originally Posted by Tony Valko View Post
    Yes, I know!

    The rant was for the benefit of others that may have an open mind.
    Actually, to be fair though, I think "pedantic" is a bit harsh.

    I come from a mathematical upbringing, so I have some sympathy with the 'purist' school which is attracted (?) by the idea of "knowing" that the most rigorous value possible has been used (no matter what the data in question).

    Of course, pragmatically, we often "know" that e.g. "zzz" or 10^10 is often more than adequate for these questions, and I often use the latter myself, but mainly since I find the use of "BigNum" to be simply aesthetically unappealing!

    For that (rather trite) reason, I don't mind REPT("z",255) - it's quite short! - and at least it saves on having to "think" of an alternative - why five "z"s, and not four, etc.?

    So I guess I'm not that fussed on this issue. If you want to know what really does annoy me, it's the use of "BigNum" in e.g. reciprocal LOOKUP constructions on an array of Booleans, where the only possible returns are either 1 or #DIV/0!.

    Now at that my mathematical hairs really do prick up on end...

    Regards

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

    Re: Alternative to using an array formula for {=LARGE(IF(... function

    You don't need the SUM function with that.

    The COUNTIFS function is an efficient function in that it will only evaluate ranges up to the size of the used range.

    For example, if you had data down to row 100, these formulas are equally efficient:

    =COUNTIFS('Sheet 1'!C:C,A8,'Sheet 1'!L:L,"N",'Sheet 1'!H:H,"*T*")

    =COUNTIFS('Sheet 1'!C1:C100,A8,'Sheet 1'!L1:L100,"N",'Sheet 1'!H1:H100,"*T*")

    For lots of tips on efficiency:

    http://www.decisionmodels.com/

  17. #17
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Alternative to using an array formula for {=LARGE(IF(... function

    I think Countifs (all the xxxIFs) function only evaluates the actual Used Range.

    But the 'Pedantic' side of me would say it's always better (at least it Never Hurts) to limit the ranges to the actual used area.

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

    Re: Alternative to using an array formula for {=LARGE(IF(... function

    Quote Originally Posted by XOR LX View Post
    If you want to know what really does annoy me, it's the use of "BigNum" in e.g. reciprocal LOOKUP constructions on an array of Booleans, where the only possible returns are either 1 or #DIV/0!.
    I am in total agreement! That's more or less what I was referring to as "pedantic".

    You HAVE to use BigNum. You HAVE to!

    LOL

  19. #19
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Alternative to using an array formula for {=LARGE(IF(... function

    Quote Originally Posted by XOR LX View Post
    So I guess I'm not that fussed on this issue. If you want to know what really does annoy me, it's the use of "BigNum" in e.g. reciprocal LOOKUP constructions on an array of Booleans, where the only possible returns are either 1 or #DIV/0!.
    +1 on that.

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

    Re: Alternative to using an array formula for {=LARGE(IF(... function

    Quote Originally Posted by tony valko View Post
    i am in total agreement! That's more or less what i was referring to as "pedantic".

    You have to use bignum. You have to!

    Lol
    lol!!

  21. #21
    Registered User
    Join Date
    05-29-2014
    Location
    West Midlands, England
    MS-Off Ver
    2011 for Mac
    Posts
    5

    Re: Alternative to using an array formula for {=LARGE(IF(... function

    Thanks for the help guys. I have no idea what you're ranting about on the side but maybe I will one day ha!

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

    Re: Alternative to using an array formula for {=LARGE(IF(... function

    Quote Originally Posted by Rabiah View Post
    Thanks for the help guys. I have no idea what you're ranting about on the side but maybe I will one day ha!
    Good point! And sorry for hijacking your thread with our esoteric rants!!

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

    Re: Alternative to using an array formula for {=LARGE(IF(... function

    I want to apologize to the OP for "hijacking" the thread and going off into the wild blue yonder!

  24. #24
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Alternative to using an array formula for {=LARGE(IF(... function

    Glad we could help, and also sorry for the hijacking..

  25. #25
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Alternative to using an array formula for {=LARGE(IF(... function

    Try this array formula in place of your formula.Naming of ranges not necessary and when data is added formula takes care of it.
    Please Login or Register  to view this content.

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

    Re: Alternative to using an array formula for {=LARGE(IF(... function

    Quote Originally Posted by kvsrinivasamurthy View Post
    Try this array formula in place of your formula.Naming of ranges not necessary and when data is added formula takes care of it.
    Please Login or Register  to view this content.
    It may not be "necessary", but given a choice between using a Named Range with INDEX and your suggestion, which is not only volatile (two "unnecessary" uses of INDIRECT), but also seems to have missed the whole point of this discussion (i.e. using whole column references with array formulas), I know which I'd take.

    Regards

  27. #27
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Alternative to using an array formula for {=LARGE(IF(... function

    Why not use the Excel Table feature instead of dynamic named ranges?
    <----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left

    If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
    I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.

  28. #28
    Registered User
    Join Date
    05-29-2014
    Location
    West Midlands, England
    MS-Off Ver
    2011 for Mac
    Posts
    5

    Re: Alternative to using an array formula for {=LARGE(IF(... function

    I don't think using Excel Table will improve the efficiency of the calculation. Ideally, I wanted a solution that didn't use an array formula at all but I can't seem to find a way around it!

  29. #29
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Alternative to using an array formula for {=LARGE(IF(... function

    Maybe it won't. The reason I suggested it is because then you don't have to think about any dynamic named range formulas.

+ 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. Alternative to Large Function
    By FF RT in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-03-2014, 06:26 AM
  2. UDF Lookup function as an alternative to array functions & match/index
    By Andrew_Harris in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-15-2012, 09:34 PM
  3. [SOLVED] Non array alternative for percentile function
    By vandan_tanna in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-22-2012, 11:43 AM
  4. Alternative to an array formula.
    By RunHard in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-16-2009, 09:18 AM
  5. Array Formula Alternative
    By smninos in forum Excel General
    Replies: 10
    Last Post: 07-15-2009, 04:31 PM

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