The Lambda function and its reliance on the Excel Name Manager

%3CLINGO-SUB%20id%3D%22lingo-sub-2279246%22%20slang%3D%22en-US%22%3EThe%20Lambda%20function%20and%20its%20reliance%20on%20the%20Excel%20Name%20Manager%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2279246%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20using%20a%20gaming%20laptop%20with%20Windows%2010%20and%20Office365.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20spreadsheets%20with%20complex%20formulas.%20I%20have%20been%20trying%20to%20use%20the%20Lambda%20function%20to%20replace%20these%20formulas%2C%20but%20I%20am%20running%20into%20issues%20because%20of%20the%20Lambda%20function's%20reliance%20on%20the%20Excel%20Name%20Manager.%26nbsp%3B%20I%20have%20a%20specific%20example%20of%20the%20problem%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20my%20gradebook%20(I%20teach%20an%20online%20class)%2C%20on%20the%20sheet%20where%20I%20use%20the%20Lambda%20function%2C%20the%20students'%20last%20names%20are%20in%20column%202%2C%20beginning%20in%20cell%20C2%20and%20extending%20down%20several%20rows%2C%20depending%20on%20how%20many%20students%20are%20in%20the%20class.%20The%20name%20of%20my%20Lambda%20function%20is%20%22Homework%22.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20a%20name%2C%20%22LastName%22%2C%20defined%2C%20and%20the%20%22Refers%20To%22%20value%20is%20%24C2.%26nbsp%3B%20The%20problem%20is%20that%20I%20cannot%20depend%20on%20this%20Refers%20To%20value%2C%20as%20the%20Name%20Manager%20keeps%20changing%20it.%26nbsp%3B%20The%20formula%20that%20uses%20this%20name%20is%20a%20formula%20that%20calculates%20a%20grade%20value%20for%20each%20student's%20homework%20for%20each%20week%20of%20the%20session.%26nbsp%3B%20When%20I%20enter%20%22%3DHomework(6)%22%20in%20the%20cell%20for%20the%20homework%20of%20the%20students%2C%20with%20the%20%226%22%20referring%20to%20the%20week%20(this%20value%20will%20be%20anything%20from%201%20to%207%20during%20a%20session)%2C%20the%20function%20usually%20returns%20an%20incorrect%20value%20until%20I%20go%20into%20the%20Name%20Manager%20and%20fix%20the%20Refers%20To%20for%20%22LastName%22.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20Name%20Manager%20usually%20has%20changed%20the%20%22Refers%20To%22%20to%20%24C%241%3B%20sometimes%20it's%20%24C1048576.%26nbsp%3B%20It%20is%20NEVER%2C%20when%20I'm%20first%20starting%20out%20to%20do%20grades%20for%20a%20given%20week%2C%20the%20reference%20I%20specified%20when%20I%20created%20the%20name%20(%24C2).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAs%20far%20as%20I%20am%20concerned%2C%20this%20is%20a%20fatal%20flaw%20for%20the%20Lambda%20function.%26nbsp%3B%20If%20I%20cannot%20depend%20on%20the%20name%20references%20I%20specified%20being%20stable%2C%20how%20can%20I%20depend%20on%20the%20Lambda%20function%20to%20return%20a%20correct%20result%3F%20Why%20must%20I%20always%20check%20the%20references%20to%20make%20sure%20Excel%20hasn't%20changed%20them%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20understand%20that%20I%20could%20fix%20this%20problem%20by%20using%20an%20explicit%20cell%20reference%20in%20the%20Lambda%20formula%20instead%20of%20an%20Excel%20name.%20The%20only%20cell%20that%20must%20be%20named%20for%20a%20Lambda%20is%20the%20one%20used%20to%20pass%20a%20value%20to%20the%20Lambda.%26nbsp%3B%20This%2C%20in%20my%20opinion%2C%20misses%20the%20point.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20if%20I%20want%20to%20use%20Excel%20names%20for%20all%20of%20my%20variables%20in%20the%20formula%2C%20and%20what%20if%20one%20of%20those%20names%20has%20a%20Refers%20To%20value%20of%20%24C2%2C%20i.e.%2C%20the%20column%20is%20fixed%20but%20the%20row%20changes%20as%20the%20formula%20is%20calculated%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20think%20Lambda's%20dependence%20on%20the%20Excel%20Name%20Manager%20is%20a%20significant%20weakness%20that%20compromises%20its%20usefulness.%20I%20have%20seen%20no%20disclaimers%20that%20warn%20a%20user%20that%20using%20Excel%20names%20in%20Lambda%20formulas%20may%20result%20in%20the%20Lambda%20returning%20an%20incorrect%20result%20for%20certain%20forms%20of%20names.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGeorge%20Rickerson%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2279246%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2279349%22%20slang%3D%22en-US%22%3ERe%3A%20The%20Lambda%20function%20and%20its%20reliance%20on%20the%20Excel%20Name%20Manager%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2279349%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1031698%22%20target%3D%22_blank%22%3E%40George_Rickerson%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EGeorge%2C%20names%20in%20Excel%20are%20connected%2C%20but%20these%20are%20different%20things.%20You%20may%20use%20LAMBDA%20only%20with%20local%20names%20without%20global%20names%20in%20name%20manager%20manager%2C%20if%20only%20to%20name%20lambda%20function.%3C%2FP%3E%0A%3CP%3ENames%20with%20relative%20references%20are%20always%20works%20such%20way%20as%20you%20described%2C%20independently%20on%20lambdas.%20If%20you%20stay%20in%20row%20%233%20and%20define%20the%20name%20as%20reference%20on%20%24C2%2C%20in%20any%20cell%20in%20second%20row%20name%20will%20show%20%24C1%2C%20if%20you%20stay%20in%20first%20row%20it%20shows%26nbsp%3B%3CSPAN%3E%24C1048576%20since%20you%20are%20out%20of%20grid%20range%20and%20reference%20reverted%20on%20the%20last%20row%20of%20the%20grid.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ELamdas%20are%20oriented%20to%20work%20with%20arrays.%20In%20your%20case%20that%20could%20be%20range%20%24C%242%3A%24C%2450%20or%20so%20named%20as%20lastName%20and%20within%20lambda%20you%20calculate%20where%20is%20data%20for%20week%206%20depends%20on%20your%20data%20structure%20logic%2C%20and%20return%20desired%20value.%3C%2FP%3E%0A%3CP%3EYou%20don't%20need%20relative%20cell%20references%20working%20with%20arrays%20and%20lambdas.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

I am using a gaming laptop with Windows 10 and Office365. 

 

I have spreadsheets with complex formulas. I have been trying to use the Lambda function to replace these formulas, but I am running into issues because of the Lambda function's reliance on the Excel Name Manager.  I have a specific example of the problem:

 

In my gradebook (I teach an online class), on the sheet where I use the Lambda function, the students' last names are in column 2, beginning in cell C2 and extending down several rows, depending on how many students are in the class. The name of my Lambda function is "Homework".

 

I have a name, "LastName", defined, and the "Refers To" value is $C2.  The problem is that I cannot depend on this Refers To value, as the Name Manager keeps changing it.  The formula that uses this name is a formula that calculates a grade value for each student's homework for each week of the session.  When I enter "=Homework(6)" in the cell for the homework of the students, with the "6" referring to the week (this value will be anything from 1 to 7 during a session), the function usually returns an incorrect value until I go into the Name Manager and fix the Refers To for "LastName".

 

The Name Manager usually has changed the "Refers To" to $C$1; sometimes it's $C1048576.  It is NEVER, when I'm first starting out to do grades for a given week, the reference I specified when I created the name ($C2).

 

As far as I am concerned, this is a fatal flaw for the Lambda function.  If I cannot depend on the name references I specified being stable, how can I depend on the Lambda function to return a correct result? Why must I always check the references to make sure Excel hasn't changed them?

 

I understand that I could fix this problem by using an explicit cell reference in the Lambda formula instead of an Excel name. The only cell that must be named for a Lambda is the one used to pass a value to the Lambda.  This, in my opinion, misses the point.

 

What if I want to use Excel names for all of my variables in the formula, and what if one of those names has a Refers To value of $C2, i.e., the column is fixed but the row changes as the formula is calculated? 

 

I think Lambda's dependence on the Excel Name Manager is a significant weakness that compromises its usefulness. I have seen no disclaimers that warn a user that using Excel names in Lambda formulas may result in the Lambda returning an incorrect result for certain forms of names.

 

George Rickerson

1 Reply

@George_Rickerson 

George, names in Excel are connected, but these are different things. You may use LAMBDA only with local names without global names in name manager manager, if only to name lambda function.

Names with relative references are always works such way as you described, independently on lambdas. If you stay in row #3 and define the name as reference on $C2, in any cell in second row name will show $C1, if you stay in first row it shows $C1048576 since you are out of grid range and reference reverted on the last row of the grid.

Lamdas are oriented to work with arrays. In your case that could be range $C$2:$C$50 or so named as lastName and within lambda you calculate where is data for week 6 depends on your data structure logic, and return desired value.

You don't need relative cell references working with arrays and lambdas.