Closed Thread
Results 1 to 16 of 16

Need Help Optimizing an Array Formula (Simplified and Updated)

  1. #1
    Forum Contributor
    Join Date
    10-05-2010
    Location
    CA
    MS-Off Ver
    Excel 365
    Posts
    539

    Question Need Help Optimizing an Array Formula (Simplified and Updated)

    PLEASE SEE POST #13 FOR AN UPDATED VERSION OF MY QUESTION

    Hello,
    I recently had help creating the formula below at this very forum. I was very fortunate to find someone to help me code an array with so many parts but due to the amount of data I wish to evaluate the formula can take up to 45 minutes to an hour to calculate. I’m hoping that someone can take a look at the array and improve upon it and hopefully make it calculate much faster.

    The rules of the formula and the formula it’s self can be found below.

    Please Login or Register  to view this content.
    RULES
    Step 1: Match the values of rows Number Combos #1 and #2 columns “J” and “K”.

    Example:
    The formula would find all rows that contain the same value for column “J” [11111] and that contain the same value for column “K” [222].

    Step 2: The formula would then determine if there are Win, Loss, or Break Even in column “L” for each matching value, if there are any, found between columns “J” and “K”.

    Step 3: After all matches were found and the formula determined if there were Win, Loss, and/or Break Even present if so the following rules would be applied for the different variations:

    If 1 Win (only) =
    All TRUE Values from columns [M to U] would be the result in columns [V to AD] in order of appearance.

    If 2+ Win (only) =
    All of the rows between them that had TRUE values in the same column for each Win from columns [M to U] would be the result in columns [V to AD] in order of appearance.

    If 1+ Loss (only) (AND/OR) 1+ Break Even (only) =
    Column “J” Number Combo #1 would be the result for [column V] (1st Instance)/Column “K” Number Combo #2 would be the result for the [column W] (2nd Instance)

    If Mix Between 1 Win (only) (AND) 1+ Loss (only) (AND/OR) 1+ Break Even (only) =
    1 Win (only): All TRUE Values from columns [M to U] would be the result in columns [V to AD] in order of appearance. (AND)
    1+ Loss/1+ Break Even: Would list in order of appearance the instances were Win was TRUE and Loss or Break Even were FALSE

    If Mix Between 2+ Win (only) (AND) 1+ Loss (only) (AND/OR) 1+ Break Even (only) =
    2+ Win (only): All of the rows between them that had TRUE values in the same column for each Win from columns [M to U] would be the result in columns [V to AD] in order of appearance.
    (AND)
    1+ Loss/1+ Break Even: Would list in order of appearance the instances were ALL 2+ Win were TRUE and Loss or Break Even were FALSE

    More Information
    L17 contains the Win and L11 and L15 contain the Losses and I need the formula to find ALL of the cells where the Losses are False but the Wins are True.

    So in other words both Losses don't have to be False in order for them to be listed as a result but all of the Wins have to be the same in order for the Losses to apply but the rule isn't the same for the Wins.

    So even though the N11 Loss is True the result for the N15 Loss should still be listed because it's False and different from the N17 True. That's why the first instance for V15 should be "B".


    I have attached spreadsheet for a better understanding.


    Thank you in advance for any and all help provided.
    Attached Files Attached Files
    Last edited by artiststevens; 04-06-2014 at 01:53 PM.

  2. #2
    Forum Contributor
    Join Date
    10-05-2010
    Location
    CA
    MS-Off Ver
    Excel 365
    Posts
    539

    Re: Need Help Optimizing an Array Formula

    Any help would be greatly appreciated.

  3. #3
    Forum Contributor
    Join Date
    10-05-2010
    Location
    CA
    MS-Off Ver
    Excel 365
    Posts
    539

    Re: Need Help Optimizing an Array Formula

    Any help would be greatly appreciated.

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Need Help Optimizing an Array Formula

    it seems that, part of building these big, ugly array formulas is to avoid using helper cells/ranges. One consequence I see in this approach is that we sometimes create extra effort for the computer in the process. For example, in your formula, there is a TRANSPOSE(ROW(range)^0) section, whose sole purpose is to calculate a horizontal array of 1's. I don't really know how long it takes a modern processor to a) look up the row number, b) raise it to the 0th power to get 1, and c) transpose that vertical array to a horizontal array, but it will take some time. Multiply that by the number of incidences of the formula across a very large data set, and this kind of duplication of effort can add to the processing time. I haven't looked at your formulas in more detail, so there may be other examples of duplication of effort. My first thought is to explore whether using helper cells/ranges to minimize this kind of duplication of effort will reduce the computation time.


    A discussion from some time ago with an example of how this duplication of effort significantly increased computation time. http://www.excelforum.com/excel-form...-and-cons.html
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  5. #5
    Forum Contributor
    Join Date
    10-05-2010
    Location
    CA
    MS-Off Ver
    Excel 365
    Posts
    539

    Re: Need Help Optimizing an Array Formula

    Thank you Mr. Shorty for the advice and sorry for the late reply. You make a lot of good points in regards to improving the process speed and the link you provided gave me a better understanding about array formulas. Unfortunately due to the fact that I’m not the original creator of the formula and that I have limited understanding of arrays there’s not much I can do with your advice.

    Could you possibly take a more detailed look at formula and provide me with a way of eliminating the helper cells/ranges?

    Thank you again for the advice you have given me thus far and I appreciate any more help/advice you can provide.

  6. #6
    Forum Contributor
    Join Date
    10-05-2010
    Location
    CA
    MS-Off Ver
    Excel 365
    Posts
    539

    Re: Need Help Optimizing an Array Formula

    Any help would be greatly appreciated.

  7. #7
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Need Help Optimizing an Array Formula

    I'm sorry, but I'm not very good with these kind of array formulas either.

    The next observation I make is that step one is simply a filtering step. I notice that you have it set up to use the autofilter tool. Perhaps by extending the idea of the filter we can improve the performance. For example, would the spreadsheet be adaptable to a situation where each J,K combination is in its own tab. If the pair sort breakdown listed is accurate, there are only 11 possible combinations of J,K values. If these were each in their own tab, then we could perhaps decrease the time of a calculation event by breaking the database up into smaller chunks.

    Reading between the lines, I expect you are seeing these long calculation events when you add an entry or make a change to an entry. When you structure a spreadsheet/database like this where all of the calculations are based on the entire database, when you make a change anywhere in the database, Excel sees the dependency as "I need to recalculate the entire block of array formulas". In reality, a change/addition to the database probably only effects about 10% of the calculated results. If we can restructure the spreadsheet/calculation so that Excel can see that you have made a change that will only effect the 11111,111 combinations (for example) so Excel can choose to only recalculate those results, we may be able to reduce the time for a calculation event.

    I'm not good at these kind of "database" calculations, so I don't know if I have any good recommendations. My first thought was to separate the big database into 11 smaller databases -- one for each J,K combination. Then, when I needed to add/change something in the 11111,222 combination, it would be done in that tab and Excel would only need to recalculate that part of the database. I expect this will dramatically reduce the time for a calculation event, but it might make maintaining the database much more difficult. Somewhere in this might need to be a discussion about balancing "I hate waiting for Excel to perform these long calculation events" against "I wish this database were easier to add/change/maintain."

  8. #8
    Forum Contributor
    Join Date
    10-05-2010
    Location
    CA
    MS-Off Ver
    Excel 365
    Posts
    539

    Re: Need Help Optimizing an Array Formula

    I understand and still appreciate the advice.

    I could combine both the J and K columns into one column but in the actual spreadsheet there are hundreds of combinations and not just 11 like in the example. If I were to put them into their own tab it would create more workbook glut.

    I do experience long calculation times with just small changes to the spreadsheet. I’ve made changes to the structure of the spreadsheet but I still experience long calculation wait times.

    I wouldn’t want to separate the database into smaller databases due the overwhelming job of having to maintain hundreds of databases. I do need to find a balance though.

    I really appreciate your attempts to help Mr. Shorty. I understand array formulas aren’t your forte. I gave you rep for your efforts. Hopefully someone with a better understanding of arrays can help me. Thank you again.

  9. #9
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Need Help Optimizing an Array Formula

    Would it be enough to set calculation to manual? Then you could make your changes/additions without interruption. Then, just as you are leaving for lunch, press F9 to initiate the calculate event, and Excel should be nearly done by the time you get back from lunch.

  10. #10
    Forum Contributor
    Join Date
    10-05-2010
    Location
    CA
    MS-Off Ver
    Excel 365
    Posts
    539

    Re: Need Help Optimizing an Array Formula

    If anyone else can provide any further help or advice it would be greatly appreciated. Thank you.

  11. #11
    Forum Contributor
    Join Date
    10-05-2010
    Location
    CA
    MS-Off Ver
    Excel 365
    Posts
    539

    Re: Need Help Optimizing an Array Formula

    Quote Originally Posted by MrShorty View Post
    Would it be enough to set calculation to manual? Then you could make your changes/additions without interruption. Then, just as you are leaving for lunch, press F9 to initiate the calculate event, and Excel should be nearly done by the time you get back from lunch.
    I already have it set to manual and I'm still making changes to the strategy so I need it to be faster so I don't have to wait so long between each change. Thanks for continuing to try to help Mr. Shorty.

  12. #12
    Forum Contributor
    Join Date
    10-05-2010
    Location
    CA
    MS-Off Ver
    Excel 365
    Posts
    539

    Re: Need Help Optimizing an Array Formula

    If anyone else can provide any further help or advice it would be greatly appreciated. Thank you.

  13. #13
    Forum Contributor
    Join Date
    10-05-2010
    Location
    CA
    MS-Off Ver
    Excel 365
    Posts
    539

    Question Re: Need Help Optimizing an Array Formula

    I’m going to make another attempt at this and see if I can simplify things. I’m looking for a way to improve upon the original array in order to speed up the calculation time.

    The original array:
    Please Login or Register  to view this content.
    IF NUMBER COMBINATIONS MATCH, THEN
    1.) If combination has "1 Win", then
    If value of the heading is True then List the "Heading Title" for ALL True headings in order of appearance for each instance

    2.) If combination has "2+ Wins", then
    If value for ALL of the 2+ Wins headings are True then list the "Heading Title" in order of appearance

    3.) If combination has "1+ Loss (and/or) Break Even", then
    "Combo#" would be the result

    4.) If combination has "1 Win" (and) "1+ Loss (and/or) Break Even", then
    If value of the heading is True for the "Win" row but False for ANY of "Loss/Break Even" rows, then
    A.) For the "Win" row list the "Heading Title" for ALL True headings in order of appearance for each instance
    B.) For the "Loss and/or Breakeven(s)" row(s) list ALL of the "Heading Title(s)" where "Win" was True and "Loss and/or Breakeven(s)" was False for headings in order of appearance for each instance

    5.) If combination has "2+ Wins" (and) "1+ Loss (and/or) Break Even", then
    If value of the heading is True for ALL of the "2+ Wins" rows but False for ALL of "Loss/Break Even" rows, then
    List the "Heading Title" in order of appearance for each instance

    The numbered examples below match the written breakdowns above.

    Example 1
    Number Combo: 11113/211
    Type(s): Win(s) - 1
    Heading Titles: A through I
    True Headings (4): A, E, F, G
    Result: A, E, F, G

    Example 2
    Number Combo: 11111/212
    Type(s): Win(s) - 3
    Heading Titles: A through I
    True Headings for ALL (3): A, F, G
    Result: A, F, G

    Example 3
    Number Combo: 11112/223
    Type(s): Loss and/or Break Even(s) - 2
    Heading Titles: A through I
    Result: 11112/223

    Example 4
    Number Combo: 11111/211
    Type(s): Win(s) - 1 (AND) Loss and/or Break Even(s) - 2
    Heading Titles: A through I
    A.) True "Win" Headings (8): B, C, D, E, F, G, H, I
    Result "Win": B, C, D, E, F, G, H, I

    B.) False "Loss and/or Break Even(s)" Headings (3): B, E, H
    Result "Loss and/or Break Even" #1: E, H
    Result "Loss and/or Break Even" #2: B, E

    Example 5
    Number Combo: 11112/211
    Type(s): Win(s) - 2 (AND) Loss and/or Break Even(s) - 2
    Heading Titles: A through I
    A.) True "Win(s)" Headings (4): B, D, F, G
    Result "Win" #1: B, D, F, G
    Result "Win" #2: B, D, F, G

    B.) False "Loss and/or Break Even(s)" Headings (3): B, F, G
    Result "Loss and/or Break Even" #1: B, F, G
    Result "Loss and/or Break Even" #2: B, F, G

    I’ve attached another spreadsheet for a better understand. Thank you in advance for any and all help.
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    10-05-2010
    Location
    CA
    MS-Off Ver
    Excel 365
    Posts
    539

    Re: Need Help Optimizing an Array Formula

    PLEASE SEE POST #13 FOR AN UPDATED VERSION OF MY QUESTION(Simplified and Updated)

  15. #15
    Forum Contributor
    Join Date
    10-05-2010
    Location
    CA
    MS-Off Ver
    Excel 365
    Posts
    539

    Re: Need Help Optimizing an Array Formula (Simplified and Updated)

    PLEASE SEE POST #13 FOR AN UPDATED VERSION OF MY QUESTION(Simplified and Updated)
    Any further help or advice would be greatly appreciated.

  16. #16
    Forum Contributor
    Join Date
    10-05-2010
    Location
    CA
    MS-Off Ver
    Excel 365
    Posts
    539

    Re: Need Help Optimizing an Array Formula (Simplified and Updated)

    PLEASE SEE POST #13 FOR AN UPDATED VERSION OF MY QUESTION(Simplified and Updated)
    Any further help or advice would be greatly appreciated.

  17. #17
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Need Help Optimizing an Array Formula (Simplified and Updated)

    Thread closed as OP request.

    He wants to post in the Commercial Services Sub forum.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

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

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Optimizing formula for counting average from all cells in column.
    By teh.format in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-24-2014, 01:09 PM
  2. Optimizing excel formula
    By a.hudrea in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 01-31-2014, 02:31 AM
  3. Optimizing my formula
    By Lurr in forum Excel General
    Replies: 7
    Last Post: 06-21-2011, 03:32 PM
  4. Optimizing formula?
    By jkenney111 in forum Excel General
    Replies: 5
    Last Post: 12-20-2006, 06:44 PM
  5. [SOLVED] Tricky array formula issue - Using array formula on one cell, then autofilling down a range
    By aspenbordr in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-27-2005, 11:05 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