+ Reply to Thread
Results 1 to 19 of 19

unable to use offset or indirect in array with non-numerical cell reference

  1. #1
    Registered User
    Join Date
    05-30-2018
    Location
    Wollongong, Australia
    MS-Off Ver
    Excel 2013
    Posts
    6

    unable to use offset or indirect in array with non-numerical cell reference

    Hi All, My first post and after hours of scouring the google, I've been left wanting, i'm very tired at present. any ways.
    Apologies in advance for not knowing how to attach a file display info easily.
    i'm attempting to do an array that looks like: {=LARGE(IF(MEMBER=$B$26,IF(LOC=$D$26,IF(SALE,(INDIRECT(MEAL))))),3)}
    also tried using offset, and looks like this: {=LARGE(IF(MEMBER=$B$26,IF(LOC=$D$26,IF(SALE,(OFFSET(SALE,0,-2))))),1)}

    the formula works with numerical cells in the data table, but the cell reference i'm attempting to display is text.
    funny thing is when using OFFSET() & INDIRECT(), on their own they display text without an issue.
    i haven't found an alternative non array type formula, or a workaround.
    I'm almost certain that when I catch up with this, #num result, we're gonna have words.
    any advise is very much appreciated.
    data table excel forum question.JPG

  2. #2
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: unable to use offset or indirect in array with non-numerical cell reference

    To attach a file go to Go Advanced (near Post Quick Reply) -> Manage Attachments -> Upload

  3. #3
    Registered User
    Join Date
    05-30-2018
    Location
    Wollongong, Australia
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: unable to use offset or indirect in array with non-numerical cell reference

    ok, i'll try that...
    Attached Files Attached Files

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,735

    Re: unable to use offset or indirect in array with non-numerical cell reference

    Try this:

    =OFFSET(SALE,MATCH(LARGE(IF(MEMBER=$B$26,IF(LOC=$D$26,SALE)),1),SALE,0)-1,-2)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: unable to use offset or indirect in array with non-numerical cell reference

    Have you tried redefining the named ranges. They include the headers.

    It also appears you are trying to apply the LARGE function to text arrays. This doesn't work.

    Other than that I am unable to understand the mission.

    Perhaps OFFSET / INDIRECT aren't the tools of choice here.

    BTW: Could you tell us what the objection is to array formulas?
    Dave

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,735

    Re: unable to use offset or indirect in array with non-numerical cell reference

    Thanks for the rep.

    Don't leave the thread hanging - if that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  7. #7
    Registered User
    Join Date
    05-30-2018
    Location
    Wollongong, Australia
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: unable to use offset or indirect in array with non-numerical cell reference

    AliGW, you are awesome. thankyou so much for your help.!!

    so elegant, ie: "try this". that worked perfectly!!!

    I haven't tested it (tried to break it) yet (will after a good night sleep) to see why the.?
    Would it be correct to evaluate that my leading with the large argument, prevented the function of the offset or indirect to calculate text?

    and FlameRetired, I though I had named ranges correct.? And I did realise my formula layout was poor, no objection to array formulas, I prefer them, as I think they look neater.

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: unable to use offset or indirect in array with non-numerical cell reference

    OK. I misinterpreted the comment about array formulas.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,735

    Re: unable to use offset or indirect in array with non-numerical cell reference

    It was nothing to do with it being text or a number - it was just a case of getting the syntax right to use the LARGE function to identify the row number that the OFFSET needed. I suggest you step through the formula using the Evaluate Formula option on the Formulas ribbon - it's very enlightening in these cases, and shows you step-by-step how a formula resolves.

  10. #10
    Registered User
    Join Date
    05-30-2018
    Location
    Wollongong, Australia
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: unable to use offset or indirect in array with non-numerical cell reference

    AliGW, thank you for your further explanation, the "-1" row reference, was confusing (cause i'm a noob), but the penny dropped eventually.

    =OFFSET(SALE,MATCH(LARGE(IF(MEMBER=$B$26,IF(LOC=$D$26,SALE)),1),SALE,0)-1,-2)
    After testing the formula on a large data set, some problems arose.

    1. the reference to the 'meal' "-1,-2)" becomes inconsistent when pasting the formula down or using it with a 'LOC' reference to other areas,
    eg: bistro, coffee shop.
    2. the 'LARGE' function becomes inconsistent when asking for the 4th largest sale,
    'meal' ")),4)" description.
    3. the named ranges had to be specified to a finite column value, not just the whole column.
    eg: $B:$B Didn't work, but $B$1:$B$40000 did work.
    4. Excel's performance slows significantly as it attempts to process the formulas, and attempting to evaluate the formula,
    excel freezes into 'not responding'.
    5. When attempting to view calculation steps, excel spits a message at me that says;
    "your formula is too long, formulas should not be longer than 8192 characters."

    Given the last two issues I believe as FlameRetired suggested to be true: "Perhaps OFFSET / INDIRECT aren't the tools of choice here."

    I will continue to search and test on other ways to tackle the issue,
    any further suggestions would be greatly appreciated,
    and I will post the solution when I find one.

  11. #11
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,181

    Re: unable to use offset or indirect in array with non-numerical cell reference

    Try

    in D29

    =LARGE(IF((Table2[LOCATION_DESCRIPTION]=$D$26)*(Table2[MEMBER_NUMBER]=$B$26),Table2[SALES]),ROWS($1:1))

    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    Then copy down

    in C29

    =INDEX(Table2[MEAL],MATCH(1,(Table2[LOCATION_DESCRIPTION]=$D$26)*(Table2[MEMBER_NUMBER]=$B$26)*(Table2[SALES]=$D29),0))


    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    Then copy down

    As you are using Excel TABLE format, you do not need named ranges as TABLES expand/contract as ROWS are Added/Deleted.

    Unlike Named Ranges, DELETING data from a TABLE e.g. using Clear Contents ,does NOT change the TABLE size.
    Attached Files Attached Files
    Last edited by JohnTopley; 06-03-2018 at 07:05 AM.

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

    Re: unable to use offset or indirect in array with non-numerical cell reference

    I was going to suggest a similar method to John, but he beat me to it.

    Roast Pork Small appears twice in your example, (rows 3 and 15) should the formula be looking at the highest individual row, or the sum of all matching rows?

    JT, your formula suffers the same fault that I was trying to correct in mine before posting, incorrect results with duplicate amounts in the sales column.

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

    Re: unable to use offset or indirect in array with non-numerical cell reference

    Taking a different approach, non array formula method.

    Delete all named ranges (except for Table2)

    In H2
    PHP Code: 
    =IF(AND([@[LOCATION_DESCRIPTION]]=$D$26,[@[MEMBER_NUMBER]]=$B$26),COUNTIFS([LOCATION_DESCRIPTION],$D$26,[MEMBER_NUMBER],$B$26,[SALES],">"&[@SALES])+COUNTIF(E$2:E2,E2),""
    Change column heading in H1 to "Rank" (without the double quotes).

    In A29
    PHP Code: 
    =SUMIFS(Table2[SALES],Table2[LOCATION_DESCRIPTION],$A$28,Table2[MEMBER_NUMBER],$B$26
    in C29
    PHP Code: 
    =INDEX(Table2[MEAL],MATCH(ROWS($C$29:$C29),Table2[Rank],0)) 
    in D29
    PHP Code: 
    =INDEX(Table2[SALES],MATCH(ROWS($C$29:$C29),Table2[Rank],0)) 
    Copy down as needed.

    Might need some changes, (see previous post).
    Attached Files Attached Files

  14. #14
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,181

    Re: unable to use offset or indirect in array with non-numerical cell reference

    Using Helper column H (which can be hidden)

    =E2+COUNTIFS($A$2:A2,A2,$B$2:B2,B2,$E$2:E2,E2)*0.00001

    in D29

    Please Login or Register  to view this content.

    NOTE: this value is the one in the helper column

    To get the TRUE sales value in D29 (column E in attached)

    Please Login or Register  to view this content.
    in C29

    Please Login or Register  to view this content.
    All array-entered
    Attached Files Attached Files

  15. #15
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,181

    Re: unable to use offset or indirect in array with non-numerical cell reference

    Or (No helper)

    In D29

    =LARGE(IF((Table23[LOCATION_DESCRIPTION]=$D$26)*(Table23[MEMBER_NUMBER]=$B$26),Table23[SALES]),ROWS($1:1))

    in C29

    =INDEX(Table23[MEAL],SMALL(IF((Table23[LOCATION_DESCRIPTION]=$D$26)*(Table23[MEMBER_NUMBER]=$B$26)*(Table23[SALES]=$D29),ROW(Table23[SALES])-ROW($E$2)+1,""),COUNTIF($D$29:$D29,$D29)))

    both array entered

    See Sheet2 of attached
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    05-30-2018
    Location
    Wollongong, Australia
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: unable to use offset or indirect in array with non-numerical cell reference

    Hi JohnTopley,
    Another thing that I've learned here today as I didn't know that before:
    "using Excel TABLE format, you do not need named ranges as TABLES expand/contract as ROWS are Added/Deleted.
    Unlike Named Ranges, DELETING data from a TABLE e.g. using Clear Contents ,does NOT change the TABLE size."
    Thank you.

    in D29
    {=LARGE(IF((Table2[LOCATION_DESCRIPTION]=$D$26)*(Table2[MEMBER_NUMBER]=$B$26),Table2[SALES]),ROWS($1:1))}
    in C29
    {=INDEX(Table2[MEAL],MATCH(1,(Table2[LOCATION_DESCRIPTION]=$D$26)*(Table2[MEMBER_NUMBER]=$B$26)*(Table2[SALES]=$D29),0))}
    entering in as an array CTRL+SHIFT+ENTER.
    I tried your suggestions; they seem to work efficiently, ie: no more Excel slowing down to a halt (freezing).
    Apart from the misinterpreting duplicate sales values it works very well!

    =E2+COUNTIFS($A$2:A2,A2,$B$2:B2,B2,$E$2:E2,E2)*0.00001
    The 'helper' column added to the end column on the table, and 'no helper' version fixed that issue.!
    That's awesome! Thank you so much!

    Correct me if I'm wrong, but the result caused by the LARGE function using the helper column,
    will always make the duplicate value the lowest (furthest down) one on the list.
    Nice touch using the "SMALL(IF" to differentiate, replacing the helper column (If I'm on the right track).

    You've got me thinking that maybe if it refers to the 'QTY' column, the product with more items sold could get ranks.
    Also, thank you for attaching the files to explain, that helps immensely.

    Hi also to, Jason.b75,
    when you mentioned: "Roast Pork Small appears twice in your example, (rows 3 and 15) should the formula be looking at the highest individual row, or the sum of all matching rows?"
    Yes the sum of, as a member can change classification in an omitted column, within the evaluated period, therefore producing two instances of the same 'MEAL' type.
    Your non array attempt is impressive also, and thank you for attaching the file example to help me understand better.
    Although I had some trouble implementing into a larger data set of ~40000 rows (maybe I didn't follow your directions exactly),
    thank you very much for your efforts!

  17. #17
    Registered User
    Join Date
    05-30-2018
    Location
    Wollongong, Australia
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: unable to use offset or indirect in array with non-numerical cell reference

    I'm going to mark the thread solved, as the original question was answered by three people, and each way worked.

    The best way for me was JohnTopley's suggestion, especially after adding in the helper and no helper versions into the formula.

    Although there are three remaining issues in my case;
    1. as Jason.b75 mentioned; find a way to sum the sales that match (matching rows) when the returned 'MEAL' is duplicated,
    but also omitted from further results.
    the cause is where the member classification had changed in the period and therefore has more than one of the same 'MEAL' items (may not even need the extra column)

    2. Find a way that the summed cells and meal types, don't reoccur in the next favourite meal results.

    3. use the QTY, value to determine the priority of the listed item if the same sales price occurs.

    I think then it will be perfect!! but may be beyond the scope of my original question.
    nevertheless I've attached the file adjusted by JohnTopley, and added in the MEMBERSHIP_TYPE column.

    Thank you again to everyone for their contribution, I'm learning a lot here, it is very much appreciated.!
    Attached Files Attached Files

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

    Re: unable to use offset or indirect in array with non-numerical cell reference

    The first 2 parts are easy enough, membership type does not need to be considered unless you only want the results relating to a single tier.

    Part 3, the tiebreaker is a little more complicated, unless I'm missing something obvious.

    Should the priority be given to highest qty, or lowest qty (highest value per single item)?

    As a side thought, have you considered the simple method?

    Filter the table, then sort the results?

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

    Re: unable to use offset or indirect in array with non-numerical cell reference

    See if this is of any use, I've added some comments to explain any ranges that are not table names, hopefully that will make it easier to copy over to your real workbook.

    I've gone for a non-array method, the downside, 3 helper columns. The first of which contains the formula that does the brunt of the work, eliminating non matching locations and member numbers, duplicate and zero value lines and totaling sales by meal.

    The second helper totals the quantities by meal for the remaining rows, the third ranks the results of the first 2 columns.

    Perhaps not the most elegant looking method, but far simpler and more efficient than the arrays that would be needed to do it without helpers (if at all possible with the revised scope).
    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] Use cell location of SMALL array formula as OFFSET reference?
    By mattmars in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-23-2016, 07:30 PM
  2. Replies: 5
    Last Post: 05-18-2016, 04:50 AM
  3. VLOOKUP with variable table array using INDIRECT and OFFSET
    By jbrizbee21 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-11-2015, 01:29 PM
  4. [SOLVED] Can't get OFFSET to accept INDIRECT cell reference
    By macaonghus in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-27-2015, 11:39 AM
  5. Replies: 3
    Last Post: 08-13-2012, 11:44 AM
  6. Replies: 2
    Last Post: 01-10-2012, 07:33 AM
  7. Indirect/Offset Column Reference
    By aldsv in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-01-2005, 11:26 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