+ Reply to Thread
Results 1 to 10 of 10

Extract values with non-array formula if condition met

  1. #1
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,012

    Extract values with non-array formula if condition met

    Looking for non-array formula to extract values starting from A32 (Unique ID heading) and B32 if the two conditions names (from A4 - maximum names is 25) and year (three years and will be manually entered)). Two conditions to be met are names (A4-A28) and year (D1-F1) criteria. If year condition met, it should extract year values (from C32.....) into C4 based on the number of names supplied. It should also extract company name into company table (starting from N4....). Same for Unique ID. This should. The main pulling criteria is the name in A4-A28. See sample file.

    Thanks
    Attached Files Attached Files
    Last edited by bjnockle; 02-01-2020 at 05:11 PM.

  2. #2
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Extract values with non-array formula if condition met

    By non-array formula, do you mean the formula needs to work correctly without being entered as an array formula? IOW, formulas could be OK if they used arrays as intermediate values as long as array formula entry wasn't required?

    Would the years in C4:L28 always be one of the years in D1:F1?

    TBH, this would be much simpler were A31:D70 one table (Table1) and the data from A4:A28, C4:L48 and N4:W28 consolidated into a 4-field by up to 250 record table (Table2) and you used MS Query to join them and produce the unique IDs that way. The 4 fields would be Index (1 to 250 = 10 years/compaies x 25 people), Company (N4:W28), Year (C4:L28), and Name (A4:A28). Maybe also a Table3 with just one field, with 3 records for the year values in D1:F1. Use inner join queries of Table1 and Table2 separately against Table3 to pull records for only the years of interest. Call those FTable1 and FTable2. Then use an inner join of FTable1 and FTable2 on Name, Year, and Company, returning FTable1.[Unique ID] and FTable2.[Index]. The Index field can be divided into row [MOD(Index-1,25)+1] and column [INT((Index+24)/25)], and that can be used to fill out the 25-row x 10-column block of Unique IDs. Dunno whether MS Query supports crosstab queries.

    Anyway, the following may be the simplest way to do this in Excel without array formulas.

    A81: Index
    B81: Company
    C81: Year
    D81: Name

    A82: 1
    A83: =A81+1

    Fill A83 down into A84:A331.

    B82: =T(INDEX($N$4:$W$28,MOD(A82-1,25)+1,INT((A82+24)/25)))
    C82: =IFERROR(INDEX($D$1:$F$1,MATCH(INDEX($C$4:$L$28,MOD(A82-1,25)+1,INT((A82+24)/25)),$D$1:$F$1,0)),"")
    D82: =T(INDEX($A$4:$A$28,MOD(A82-1,25)+1))

    Select B82:D82 and fill down into B83:D331. Note that the col C formulas ensure than years from C4:L28 appear in D1:F1 or these formulas return "" which appear blank.

    Now supplement with match-up formulas.

    E82: =IF(COUNT(C82),MATCH(1,INDEX((D82=$D$32:$D$70)*(C82=$C$32:$C$70)*(B82=$B$32:$B$70),0),0),"")

    Fill E82 down into E83:E331. This most definitely USES arrays, but it doesn't require array formula entry thanks to INDEX(array_expression,0).

    Now populate N32:W56 with formulas.

    N32: =IF(COUNT(INDEX($E$82:$E$331,ROWS($N$32:N32)+(COLUMNS($N$32:N32)-1)*25)),INDEX($A$32:$A$70,INDEX($E$82:$E$331,ROWS($N$32:N32)+(COLUMNS($N$32:N32)-1)*25)),"")

    Copy N32 and paste into N32:W56.

    Not particularly elegant. Doing this in MS Query (which comes bundled with Office) with SQL queries and ideally a CROSSTAB query at the end would be much more elegant. If there's a more elegant way to do this with non-array formulas, someone else will need to come up with it.

    ADDED: A few minutes after posting this, the more direct solution hit me. Dispense with all the formulas above.

    N32: =IFERROR(INDEX($A$32:$A$70,MATCH(1,INDEX(($A4=$D$32:$D$70)*(C4=$C$32:$C$70)*(N4=$B$32:$B$70),0),0)),"")

    Copy N32, paste into N32:W56. I must have been way too fixated on the SQL approach. Note, however that this doesn't ensure that C4:L28 year values are in D1:F1. For that, use

    N32: =IFERROR(INDEX($A$32:$A$70,MATCH(1,INDEX(($A4=$D$32:$D$70)*(INDEX($D$1:$F$1,MATCH(C4,$D$1:$F$1,0))=$C$32:$C$70)*(N4=$B$32:$B$70),0),0)),"")
    Last edited by hrlngrv; 02-01-2020 at 08:35 PM.

  3. #3
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,012

    Re: Extract values with non-array formula if condition met

    Hrlgrv: Yes, the formula needs to be created as non-array (meaning with CTRL + ALT + Enter. This is to limit the heavily memory processing required for array formula as my data set is about 200,000 rows. Do not mind using helper columns to make it non-array and easy on computing time.

    Thanks

  4. #4
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Extract values with non-array formula if condition met

    Quote Originally Posted by bjnockle View Post
    . . . This is to limit the heavily memory processing required for array formula . . .
    One array formula performing 2 operations on 200,000 cells really won't use appreciably more memory or CPU time than 200,000 separate formulas each performing 2 operations on 1 cell each. Where supporting formulas become handy is avoiding redundant calculations, e.g., N cells each calling INDEX and MATCH in which other INDEX arguments vary but the MATCH call is identical between all N formulas. Better to use N+1 cells, with the MATCH call in its own cell, and the N INDEX calls referring to the cell with the MATCH formula.

    That said, my MATCH(1,INDEX((a=range1)*(b=range2)*(c=range3),0),0) is relatively inefficient, but it means the formulas using it don't require array formula entry. Array formulas REQUIRING array formula entry but using MATCH(TRUE,IF(a=range1,IF(b=range2,c=range3)),0) would be MORE EFFICIENT because c=range3 comparisons are only performed when corresponding b=range2 and a=range1 comparisons were TRUE, and b=range2 comparisons are only performed when corresponding a=range1 comparisons were TRUE.

    It's often the case that you'll actually perform MORE underlying operations, using more RAM, taking more CPU time avoiding array formulas for what array formulas do best. Multiple comparisons across several conforming arrays is actually something array formulas handle more efficiently than non-array formula alternatives.

  5. #5
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,012

    Re: Extract values with non-array formula if condition met

    hrlngrv: This formula pulled correctly for the Unique ID table (N32:W56) when the criteria in Table A4:A28 and B1:F1 is met. However, it is not pulling for C4:L28 when I copied the formuala into this table. It did not pull for N4:W28 as well. Are you able to modify this formula =IFERROR(INDEX($A$32:$A$70,MATCH(1,INDEX(($A4=$D$32:$D$70)*(INDEX($D$1:$F$1,MATCH(C4,$D$1:$F$1,0))=$C$32:$C$70)*(N4=$B$32:$B$70),0),0)),"") to pull for these two other tables?

    Note: Would the years in C4:L28 always be one of the years in D1:F1? Answer: No, the years in C4:L28 are to be pulled by formula based on manual data entry in A4:A28 (names in A4:A28 are going to be manually entered) and the years in D1:F1 are to going to manually entered as well. I only used 2000, 2001 and 2002 for this sample. It could be 2001, 2002 and 2003 or 2002, 2003 and 2004. The goal is now for the formula to look through A32:D70 and extract the values for C4:L28 if A4:A28 and D1:F1 criteria is met.

    Thanks
    Last edited by bjnockle; 02-02-2020 at 09:49 AM.

  6. #6
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Extract values with non-array formula if condition met

    The formula works for me with your original data and with F1 changed to 2005.

    Here's a link to the workbook in which I tested this using Excel Online. With D1:F1 unchanged from what you provided, it produces the same results as in your N32:N56. With F1 changed to 2005, the results under Unique ID 1 remain the same, but the result under Unique ID 2 disappears.

    If my formulas isn't working on your end, please provide another example workbook using my formula and producing incorrect results because my formula in your original workbook works for me, so I can't diagnose anything wrong.

  7. #7
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,012

    Re: Extract values with non-array formula if condition met

    hrlngrv: Yes, it is working for pulling Unique ID but NOT working for the Year Table (C4:L28) - should pull year data from column C32:C70 into C4:L28 and NOT working for Company Table (N4:W28). These two tables are to be populated with formula.

    Thanks

  8. #8
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Extract values with non-array formula if condition met

    Quote Originally Posted by bjnockle View Post
    . . . NOT working for the Year Table (C4:L28) - should pull year data from column C32:C70 into C4:L28 and NOT working for Company Table (N4:W28). These two tables are to be populated with formula. . . .
    I hadn't realized these requirements from your original post.

    Most obvious 1st question: 10 columns for years in C4:L28 based on 3 calendar years in D1:F1? These people change company frequently during any given year?

    One thing which led me to believe you only needed formulas for N32:W56 was that the name in A4 appears in D33, and the year in C33 appears in D1. While that same year also appears in cell C4, the company in N4 is not the company in B33, but the company in B53. I have to ask whether A32:D70 is unsorted yet you want results in C4:L28 and N4:W28 as if A32:D70 were sorted by company. If so, that makes this rather difficult and extremely inefficient. If you want to show results for company Lanky first, why not sort A32:D70 first by name, then by company, then by year? If you have to use the A32:D70 data in the order given, then I'll return to my original suggestion: use MS Query.

  9. #9
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,012

    Re: Extract values with non-array formula if condition met

    hrlngrv: Most obvious 1st question: 10 columns for years in C4:L28 based on 3 calendar years in D1:F1? The company pulled may not necessarily be 10. Only used 10 columns to make sure values are captured if more than 5 companies are extracted. These people change company frequently during any given year? They sometime do. Data is not sorted and does not need to be sorted.

    Thanks

  10. #10
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Extract values with non-array formula if condition met

    Follow the link I provided in #6 above. I changed my approach entirely. The key formulas are in F32:J70. The C4:L28, N4:W28 and N32:W56 formulas become relatively simple INDEX MATCH wrapped in IFERROR. The key is the H32:I70 formulas which determine the column (C4:L28, etc) a particular result should appear in for a given name.

+ 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. Extract values with non-array formula
    By bjnockle in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 01-18-2020, 07:49 PM
  2. Non-Array formula to extract values
    By bjnockle in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-15-2020, 10:38 PM
  3. Non Array Formula to Extract Values if criteria met
    By bjnockle in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-16-2018, 12:48 AM
  4. Non Array Formula to Extract Values
    By bjnockle in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 03-31-2018, 04:50 AM
  5. Replies: 11
    Last Post: 10-27-2016, 07:33 PM
  6. [SOLVED] Sum Large values along with Count Condition - Array Formula
    By acsishere in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-28-2013, 05:45 PM
  7. Replies: 3
    Last Post: 11-24-2011, 06:11 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