• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Get the value from the second last occurrence

Good day everyone,

I have a set of data where a combination (product/location/batch number) reoccurs. When I extend the dataset with latest information (number of days left to sell for a batch), I need to get the comment based on my notes from the last time I had reviewed the combination.

Example:

Feb-23 notes
A-xyz-123 - Will be sold to Costco by mid April
Mar-23 notes
A-xyz-123 - comments section is blank (because I didn’t have time
In April-23, when I paste the combination 100 Rows below the above, I need the comment from Feb-23 “Will be sold to Costco by mid April” to appear against this.

Hope this makes sense.
Thanks for your help.
Cheers
 
This seems to do what is asked for, but there must be a simpler way, and one that does not require Excel 365.
Code:
=BYROW(
    table,
    LAMBDA(thisRow,
        LET(
            currentProduct, (thisRow product),
            currentComment, (thisRow comment),
            partListProducts, product1:currentProduct,
            partListComments, comment1:currentComment,
            listOfMatches, FILTER(
                partListComments,
                partListProducts = currentProduct,
                "not found"
            ),
            IFERROR(CHOOSEROWS(listOfMatches, -2), "None found")
        )
    )
)
 

Attachments

  • priorComment.xlsx
    14.1 KB · Views: 4
Back
Top