SOLVED

Need help on Lambda #VALUE error

%3CLINGO-SUB%20id%3D%22lingo-sub-2287713%22%20slang%3D%22en-US%22%3ENeed%20help%20on%20Lambda%20%23VALUE%20error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2287713%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Experts%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20help%20me%20to%20catch%20the%20error%20with%20below%20LAMBDA%20function%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DLAMBDA(DOP%2CSqdop%2CSqEoo%2CModel%2CSqModel%2CInsname%2CSqinsname%2COfferName%2CIFS(AND(DOP%26gt%3B%3DSqdop%2CDOP%26lt%3B%3DSqEoo%2CModel%3DSqModel%2CInsname%3DSqinsname)%2COfferName))%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAfter%20passing%20the%20correct%20parameters%20it%20is%20still%20show%20the%20%23value%20error%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2287713%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2288278%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20help%20on%20Lambda%20%23VALUE%20error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2288278%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1036067%22%20target%3D%22_blank%22%3E%40Manish4993%3C%2FA%3E%26nbsp%3BDifficult%20to%20diagnose%20this%20without%20seeing%20the%20file%20and%20the%20formula%20at%20work.%20But%20the%20MS%20support%20page%20for%20LAMBDA%20says%20this%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Screenshot%202021-04-25%20at%2016.15.21.png%22%20style%3D%22width%3A%20448px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F275376i88DB14AC1DB28622%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Screenshot%202021-04-25%20at%2016.15.21.png%22%20alt%3D%22Screenshot%202021-04-25%20at%2016.15.21.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3ESo%2C%20are%20you%20really%20passing%20all%20(and%20not%20too%20many)%20arguments%3F%20And%20I%20assume%20that%20you%20have%20named%20your%20function%20something%20like%20%22CheckDOP%22%20in%20the%20Name%20Manger%20and%20that%20the%20Lambda%20function%20expression%20is%20entered%20there.%20And%20then%2C%20when%20you%20call%20the%20function%20you%20enter%20something%20like%20%3DCheckDOP(..........)%20with%20all%20eight%20parameters%20between%20the%20brackets.%3C%2FP%3E%3CP%3EIf%20all%20of%20this%20makes%20no%20sense%20at%20all%2C%20perhaps%20you%20can%20upload%20you%20workbook.%20Remove%20any%20private%20or%20confidential%20information%2C%20though.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2288457%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20help%20on%20Lambda%20%23VALUE%20error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2288457%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403176%22%20target%3D%22_blank%22%3E%40Riny_van_Eekelen%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%20Riny%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20find%20the%20attachment%20for%20better%20understanding%20of%20problem.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2288508%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20help%20on%20Lambda%20%23VALUE%20error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2288508%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1036067%22%20target%3D%22_blank%22%3E%40Manish4993%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20call%26nbsp%3Bwith%20has%209%20parameters%20lambda%20which%20has%20only%208%20ones.%20If%20you%20have%20no%20recursion%20it's%20always%20better%20to%20test%20formula%20on%20simple%20LET%20and%20after%20that%20wrap%20by%20LAMBDA%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DLET(%0A%20DOP%2C%20%20%20%20%20%20%20Data!B2%2C%0A%20Sqdop%2C%20%20%20%20%20'Sales%20Qty'!E2%2C%0A%20SqEnd%2C%20%20%20%20%20Data!B2%2C%0A%20Model%2C%20%20%20%20%20'Sales%20Qty'!F2%2C%0A%20Sqmodel%2C%20%20%20Data!A2%2C%0A%20INSname%2C%20%20%20'Sales%20Qty'!D2%2C%0A%20SqInsname%2C%20Data!E2%2C%0A%20Offername%2C%20'Sales%20Qty'!C2%2C%0A%20IFS(AND(DOP%26gt%3B%3DSqdop%2CDOP%26lt%3B%3DSqEnd%2CModel%3DSqmodel%2CINSname%3DSqInsname)%2COffername%2C%0A%20%20%20%20%20TRUE%2C%20'Sales%20Qty'!A2)%0A)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2288537%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20help%20on%20Lambda%20%23VALUE%20error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2288537%22%20slang%3D%22en-US%22%3EBoth%20the%20data%20set%20ranges%20will%20go%20long%20and%20i%20will%20also%20use%20the%20recursion%20to%20make%20it%20dynamic.%20So%20i%20don't%20know%20the%20actual%20error%20that%20need%20to%20be%20solved%20as%20pet%20attached%20file.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2288551%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20help%20on%20Lambda%20%23VALUE%20error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2288551%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1036067%22%20target%3D%22_blank%22%3E%40Manish4993%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EActual%20error%20is%20different%20number%20of%20parameters%20in%20function%20and%20it's%20call.%3C%2FP%3E%0A%3CP%3EAll%20the%20rest%20is%20more%20about%20how%20to%20avoid%20such%20errors%2C%20one%20of%20main%20techniques%20is%20in-cell%20editing.%20With%20some%20tricks%20that%20could%20be%20used%20for%20the%20function%20with%20recursion.%20But%20that's%20in%20theory%2C%20you%20concrete%20function%20doesn't%20have%20recursion.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi Experts,

 

Please help me to catch the error with below LAMBDA function:

 

=LAMBDA(DOP,Sqdop,SqEoo,Model,SqModel,Insname,Sqinsname,OfferName,IFS(AND(DOP>=Sqdop,DOP<=SqEoo,Model=SqModel,Insname=Sqinsname),OfferName))

 

After passing the correct parameters it is still show the #value error

11 Replies

@Manish4993 Difficult to diagnose this without seeing the file and the formula at work. But the MS support page for LAMBDA says this:

Screenshot 2021-04-25 at 16.15.21.png

So, are you really passing all (and not too many) arguments? And I assume that you have named your function something like "CheckDOP" in the Name Manger and that the Lambda function expression is entered there. And then, when you call the function you enter something like =CheckDOP(..........) with all eight parameters between the brackets.

If all of this makes no sense at all, perhaps you can upload you workbook. Remove any private or confidential information, though.

@Riny_van_Eekelen 

 

Hi Riny,

 

Please find the attachment for better understanding of problem.

@Manish4993 

You call with has 9 parameters lambda which has only 8 ones. If you have no recursion it's always better to test formula on simple LET and after that wrap by LAMBDA

=LET(
 DOP,       Data!B2,
 Sqdop,     'Sales Qty'!E2,
 SqEnd,     Data!B2,
 Model,     'Sales Qty'!F2,
 Sqmodel,   Data!A2,
 INSname,   'Sales Qty'!D2,
 SqInsname, Data!E2,
 Offername, 'Sales Qty'!C2,
 IFS(AND(DOP>=Sqdop,DOP<=SqEnd,Model=Sqmodel,INSname=SqInsname),Offername,
     TRUE, 'Sales Qty'!A2)
)

 

Both the data set ranges will go long and i will also use the recursion to make it dynamic. So i don't know the actual error that need to be solved as pet attached file.

@Manish4993 

Actual error is different number of parameters in function and it's call.

All the rest is more about how to avoid such errors, one of main techniques is in-cell editing. With some tricks that could be used for the function with recursion. But that's in theory, you concrete function doesn't have recursion.

If possible please share the correct formula file with me by using the same file that earlier i shared with you.
best response confirmed by Manish4993 (Occasional Contributor)
Solution

@Manish4993 Just as I suspected and @Sergei Baklan pointed out, you have one argument too many. See attached.

Screenshot 2021-04-25 at 20.11.45.png

@Manish4993 

It depends on which logic is to be for the last parameter. For example

=LAMBDA(DOP,Sqdop,SqEnd,Model,Sqmodel,INSname,SqInsname,Offername,Othername,
   IFS( AND(
         DOP>=Sqdop,
         DOP<=SqEnd,
         Model=Sqmodel,
         INSname=SqInsname
       ),Offername,
      TRUE, Othername))(Data!B2,
                       'Sales Qty'!E2,
                        Data!B2,
                       'Sales Qty'!F2,
                        Data!A2,
                       'Sales Qty'!D2,
                        Data!E2,
                       'Sales Qty'!C2,
                       'Sales Qty'!A2)

Function is G2. If logic is correct you may remove parameters and add to Name Manager.

@Riny_van_Eekelen

 

i need one more help.

How to use recursion in same file. updated file is attached for reference.  

@Manish4993 Not sure what you mean, but am wondering why you are using LAMBDA in the first place. Your goal is not very complicated and can be achieved by using FILTER. I've transformed your data to structured tables, so that the filtering becomes easier to follow. The end result is in column G.

 

If you are merely doing this to learn LAMBDA formulae, someone else has to jump in and answer the part on recursion.

@Manish4993 

I also have no idea why do we need recursion here and what to iterate with it.

That's not an answer on direct question, but simplest way to return the result without copying the formula is to use structured table with simple formula like

=IFNA(INDEX(Sales[Offer Name], XMATCH(1,
   ([@[Date of purchase]]>=Sales[Adjusted Start Date])*
   ([@[Date of purchase]]<=Sales[Adjusted End Date])*
   ([@Model]=Sales[Model])*
   ([Insuranace name]=Sales[Insuranace Type]))), "no such" )