Consulting

Results 1 to 5 of 5

Thread: Auto commentary function

  1. #1
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location

    Auto commentary function

    I recently came across this Lambda function in a worksheet.

    =AUTOCOMMENTARY(Heading, ComparativeName, SubHeadings, BaseValues, ComparativeValue, Reasons, _
    SortOrder, PlusWord, MinusWord, StatementNumberFormat, VarianceNumberFormat, Threshold, DecimalAccuracy)
    In the attached workbook there are a number of examples of how it may be applied. My question is largely based on where does this formula reside? It doesn't appear to be an Office 365 for Mac function.
    Attached Files Attached Files
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  2. #2
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,198
    Location
    It's a custom function that has been created from what I can see, you will find it in the name manager. It has been added to the spreadsheet itself, it kind of acts like a UDF in the way it works, difference being, it is a LAMBDA function rather than a UDF.

    Below is some of the logic:
    =LAMBDA(Heading,ComparativeName,SubHeadings,BaseValues,ComparativeValues,Reasons,SortOrder,PlusWord,MinusWord,StatementNumberFormat,VarianceNumberFormat,Threshold,DecimalAccuracy,LET(BaseTotal, ROUND(SUM(BaseValues), DecimalAccuracy), ComparativeTotal, ROUND(SUM(ComparativeValues), DecimalAccuracy), VarianceTotal, ROUND(BaseTotal - ComparativeTotal, DecimalAccuracy), VarianceValues, ROUND(BaseValues - ComparativeValues, DecimalAccuracy), SortOrderValues, IF(ABS(SortOrder) = 2, ROUND(ABS(BaseValues - ComparativeValues), DecimalAccuracy), ROUND(BaseValues - ComparativeValues, DecimalAccuracy)), isAre, IF(RIGHT(Heading, 1) = "s", "are", "is"), TempArray, SORT(FILTER(HSTACK(VarianceValues, SortOrderValues, SubHeadings & " variance of " & TEXT((VarianceValues), VarianceNumberFormat) & IF(ISBLANK(Reasons), "", " due to " & Reasons)), ABS(VarianceValues) >= Threshold, {0,0,"N/A"}), 2, IF(SortOrder < 0, -1, 1)), ReasonList, TEXTJOIN("; ", TRUE, DROP(TempArray, , 2)), UnanalyzedTotal, VarianceTotal - ROUND(SUM(TAKE(TempArray, , 1)), DecimalAccuracy), ReasonsError, ISERROR(TAKE(TempArray, 1, 1)), IndexItem, SWITCH(TRUE, VarianceTotal = 0, 1, ABS(VarianceTotal) < Threshold, 1, ReasonsError = TRUE, 2, 3), TempStack, VSTACK(Heading & " of " & TEXT(BaseTotal, StatementNumberFormat) & " " & isAre & " " & "inline with " & ComparativeName & ".", Heading & " of " & TEXT(BaseTotal, StatementNumberFormat) & " " & isAre & " " & TEXT(VarianceTotal, VarianceNumberFormat) & " " & IF(VarianceTotal < 0, MinusWord, PlusWord) & " " & ComparativeName & ". This is driven by variances below " & TEXT(Threshold, StatementNumberFormat) & ".", Heading & " of " & TEXT(BaseTotal, StatementNumberFormat) & " " & isAre & " " & TEXT(VarianceTotal, VarianceNumberFormat) & " " & IF(VarianceTotal < 0, MinusWord, PlusWord) & " " & ComparativeName & "." & " This is driven by " & ReasonList & IF(UnanalyzedTotal = 0, ".", "; the remaning varaince of " & TEXT(UnanalyzedTotal, VarianceNumberFormat) & " relates to items below " & TEXT(Threshold, StatementNumberFormat) & ".")), CHOOSEROWS(TempStack,
    The rest seems to cut off for me when i try to copy it.
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2403, Build 17425.20146

  3. #3
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    There's something about these Lambda functions..... they tend to hide the War & Peace novels all too neatly. Yoda. I need your help please.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  4. #4
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,198
    Location
    I tend not to use LAMBDA in this way, I tend to use it within a formula that requires LAMBDA. Thats not to say there is anything wrong with using it in this way. As you stated, it hides the logic.

    "Long this formula is"
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2403, Build 17425.20146

  5. #5
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    I confused am.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •