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

Recursion in excel with Lambda

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]

Want to read more?

Check out the full article on the original site

View original article

Tagged with

#Excel compatibility
#rows.com
#Excel alternatives for data analysis
#AI formula generation techniques
#financial modeling with spreadsheets
#Recursion
#Excel
#Lambda
#XLOOKUP
#Function
#Units Sold
#Dates
#Table
#Formula
#Closest Previous Date
#Comparison
#Previous Date
#Output
#Alternative
#Error Handling