+ Reply to Thread
Results 1 to 10 of 10

How to use additional range within LAMBDA

  1. #1
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    UK
    MS-Off Ver
    365
    Posts
    636

    How to use additional range within LAMBDA

    Hi, attached a sample of what I am trying to do.

    Essentially my starting point is:
    Please Login or Register  to view this content.
    That is, simply a growing counter when data is avialable in a data range, otherwise leave counter constant.

    Then, in cell J4, I was trying to amend the formula to incorporate another condition within the LAMBDA-function based results of another input range called x:
    Please Login or Register  to view this content.
    While the formula is not working, it is supposed to check each iteration of a also the corresponding value of the range x and then apply the rest of the calculation accordingly.

    Happy if someone can explain why this is not working/how to fix it.

    Thanks
    Attached Files Attached Files

  2. #2
    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. 2407 (Windows 11 23H2 64-bit)
    Posts
    83,181

    Re: How to use additional range within LAMBDA

    I can, I think, explain why it's not working with a link:

    https://bettersolutions.com/excel/fu...n-function.htm

    SCAN is looking at the values that it is generating from row to row: if you interrupt that pattern of generation (or try to), then it's clearly going to fall over.

    I don't know a way of doing this. Someone else may find a way.
    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.

  3. #3
    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. 2407 (Windows 11 23H2 64-bit)
    Posts
    83,181

    Re: How to use additional range within LAMBDA

    Just to try to illustrate a bit better what I mean (and I have no idea if this will make any sense to anyone else, but it does to me), this:

    Please Login or Register  to view this content.
    produces this:

    AliGW on MS365 Beta Channel (Windows 11) 64 bit

    G
    4
    1
    5
    2
    6
    1
    7
    1
    8
    4
    Sheet: Sheet1

    However, this may give someone else an idea - who knows?

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,188

    Re: How to use additional range within LAMBDA

    The first problem is that "a" is initially 0 so the index is returning the entire array. if you change it to a+1 it will work with that data, but if you make D7 blank & put something in E7 it will give the wrong answer as the value of "a" is not sequential & so is looking at the wrong row.

  5. #5
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    UK
    MS-Off Ver
    365
    Posts
    636

    Re: How to use additional range within LAMBDA

    Hmm, ok, makes sense whith the initial zero value.
    Ignoring for a moment the actual counter working with the variables a and b (I just plugged 1 and 2 values into the IF-branches), why does this still produce a calc error?
    Please Login or Register  to view this content.
    N4# is the length evaluation of the concatenated strings: {3;0;3;2;0;3;0;0}

    I assume this is still the same or a similar underlying issue with nested arrays?
    Attached Files Attached Files
    Last edited by RaulSerg; 05-26-2024 at 11:57 AM.

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,188

    Re: How to use additional range within LAMBDA

    Because "s" is an array the index is returning multiple values, not a single value.

  7. #7
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,188

    Re: How to use additional range within LAMBDA

    One way to do it is
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  8. #8
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    UK
    MS-Off Ver
    365
    Posts
    636

    Re: How to use additional range within LAMBDA

    Oh thanks, that's quite neat.

    Without much success so far, I have currently been looking into this:
    https://stackoverflow.com/questions/...e-same-formula
    which looks like a somewhat similar problem and tried to adjust the MAP / REDUCE solutions there to my scenario.

  9. #9
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,188

    Re: How to use additional range within LAMBDA

    Glad to help & thanks for the feedback.

  10. #10
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    UK
    MS-Off Ver
    365
    Posts
    636

    Re: How to use additional range within LAMBDA

    btw - I think I figured that - at least in my example, the range in column E actually seems irrelevant for generating the desired output.
    I think also in your formula, Fluff13, appending the range &E4:E8 doesn't really do anything, does it?

    So, in the example the following slightly shorter version yields the same result:
    Please Login or Register  to view this content.
    And this is also equivalent to:
    Please Login or Register  to view this content.
    So, at least my take-away is that the maniupulation of the range passed to SCAN is the important bit rather than to fiddle around too much within the LAMBDA piece which may mess up the accumulator variable.
    And then this made me realise that maybe the concatenation and TEXT-xxx part isn't really needed at all:
    Please Login or Register  to view this content.

+ 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. Recursive lambda
    By Glenn Kennedy in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 02-13-2024, 11:51 AM
  2. Need help getting LAMBDA to work
    By Newtonus_Prime in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-21-2023, 09:15 AM
  3. [SOLVED] Lambda to count specific cell colors in a range
    By jaryszek in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-22-2022, 11:37 AM
  4. [SOLVED] LAMBDA iteration
    By Slabu in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 07-20-2021, 08:39 PM
  5. Replies: 8
    Last Post: 03-01-2021, 05:41 PM
  6. Replies: 2
    Last Post: 01-09-2018, 10:05 AM
  7. Count a single range using additional criteria from another range
    By FatFoot in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-27-2013, 08:40 PM

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