1 min readfrom Microsoft Excel | Help & Support with your Formula, Macro, and VBA problems | A Reddit Community

Recursion in excel with Lambda

Our take

Struggling to get accurate sales data from your Excel table? Recursion with LAMBDA can transform your approach, allowing you to dynamically compare dates and retrieve units sold, even when the table skips entries. By leveraging LAMBDA and XLOOKUP, you can create a function that finds the closest previous date with available data. While you've tried stopping recursion with your formula, there may be simpler strategies to achieve the same goal. Keep reading to discover effective methods to optimize your Excel functions for better insights.

Hi! I'm trying to write a recursive function that will compare a given date to a table, and output the units sold. As the table skips dates, the functions should try to find the closest previous date of units sold. Tried the formula below to stop the recursion if xlookup returns a value, but doesn't work. Any help would be appreciated!

=LAMBDA (n, IF(n<>#N/A,XLOOKUP(n, CookiesTable[Date], CookiesTable[Units Sold]), XLOOKUP(n,CookiesTable[Date], CookiesTable[Units Sold], XLOOKUP(n -1,CookiesTable[Date], CookiesTable[Units Sold]))))

EDITED: Alternative way of doing this w/o recursion has been stated in comment section.

submitted by /u/CLattePanda
[link] [comments]

Read on the original site

Open the publisher's page for the full experience

View original article