+ Reply to Thread
Results 1 to 9 of 9

Question about Lambda

  1. #1
    Forum Contributor
    Join Date
    10-02-2023
    Location
    Singapore
    MS-Off Ver
    Microsoft 365
    Posts
    201

    Question about Lambda

    Hi, i am very confuse about the syntax of Lambda, please refer attached.
    I am doing a Textjoin by criteria thing. (its own exercies)
    My formula in D2 work, but i Memories it rather than Understand it.
    I do not understand why is it like that. I written down my question in the excel in yellow.

    Also, after i textjoin, i try to textsplit back to original using formula, but i do not know how.


    Anyway can help shine some light?
    Attached Files Attached Files

  2. #2
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2405-17628.20102
    Posts
    1,404

    Re: Question about Lambda

    From my understanding, within a LET formula, the letters x and q are like variables, then only become what you define them as. for example:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Will mean that the value of x becomes the below:
    A
    B
    C
    D

    So x is an array of values and not just one.

    With that in mind, when you use the BYROW function, it requires a LAMBDA in order to loop through the values of x. For example:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    In the above, the q becomes A then B then C then D as the LAMBDA loops through the values of x.

    So the LAMBDA part is doing a TEXTJOIN using each value within x by looking up the values in your table, so it finds:

    A - China, SG
    B - SG, Msia
    Etc..

    The formula then stacks horizontally, the result of x and then the results for the TEXTJOIN's.

    Sorry if this is not clear, this is the way I learned how the LAMBDA works, I actually come from a VBA coding background.

    As for the formula to convert the values back, the below could be an option, although there may be many variations that do the same:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by CheeseSandwich; 04-26-2024 at 07:13 AM.
    If things don't change they stay the same

  3. #3
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,465

    Re: Question about Lambda

    Here is another solution to convert the values back:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    10-02-2023
    Location
    Singapore
    MS-Off Ver
    Microsoft 365
    Posts
    201

    Re: Question about Lambda

    @CheeseSandwich

    Hi, thanks for the detailed explanation. Does that mean the q as in "Lambda(q" can only refer to a single cell?
    Last edited by AliGW; 05-03-2024 at 11:49 AM. Reason: Please don't quote unnecessarily - use the Quick Reply button instead.

  5. #5
    Forum Contributor
    Join Date
    10-02-2023
    Location
    Singapore
    MS-Off Ver
    Microsoft 365
    Posts
    201

    Re: Question about Lambda

    Hi Hans, thanks for your solution. Helpful as i can better understand how the Lambda works.

  6. #6
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2405-17628.20102
    Posts
    1,404

    Re: Question about Lambda

    q refers to a single instance of x

  7. #7
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,465

    Re: Question about Lambda

    Quote Originally Posted by FT00 View Post
    HDoes that mean the q as in "Lambda(q" can only refer to a single cell?
    No.
    In BYROW(x,LAMBDA(q,... q ferfers each time to a single row: The first time q refers to the first row of x, the second time q refers to the second row of x etcetera,
    where in your example x is equal to UNIQUE(Table1[Name])

    In MAP(x,LAMBDA(q,..., q can only refer ro a single cell.
    Last edited by HansDouwe; 04-27-2024 at 06:01 AM.

  8. #8
    Forum Contributor
    Join Date
    10-02-2023
    Location
    Singapore
    MS-Off Ver
    Microsoft 365
    Posts
    201

    Re: Question about Lambda

    Thanks Hans for your explanation. Sorry for the late reply.

    Sorry, i am still trying to learn Lambda logic, hence might ask quite stupid question....=(

  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. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,800

    Re: Question about Lambda

    No such thing - until you know, you don't know. I progress in fits and starts with LAMBDA, with a lightbulb moment every now and again. Lots of tiral and (frustrating) error will get you there eventually.
    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.

+ 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] Using TEXTSPLIT with MAP and LAMBDA is not working
    By Jacc in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-17-2023, 03:15 PM
  4. [SOLVED] Maximum Drawdown and LAMBDA
    By andrewc in forum Excel General
    Replies: 5
    Last Post: 06-28-2023, 09:25 AM
  5. [SOLVED] Replace Repetitive Formulas With Lambda?
    By helmanfrow in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 03-26-2023, 06:57 AM
  6. [SOLVED] LAMBDA iteration
    By Slabu in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 07-20-2021, 08:39 PM
  7. Lambda Expressions in Excel VBA
    By Gregor y in forum Tips and Tutorials
    Replies: 4
    Last Post: 10-17-2014, 06:59 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