Forum Discussion
Additional help needed with existing formula using LAMDA- Excel 365
- Aug 24, 2025
I reorganized the sample file, so each table now contains the same number of columns, in the same order, as the updated SheetMap. The only thing I had to change about the formula (from rev3.0) was the _cId variable to set the field mapping:
=LET( _rep, RESULTS!$A$2, _beg, RESULTS!$B$2, _end, RESULTS!$C$2, _lst, RESULTS!$A$5:$A$12, _inc, (RESULTS!$E$5:$E$12="EXCEED")+(RESULTS!$E$5:$E$12="NOT MET"), IF( NOT(OR(_inc)), "[no records found]", LET( VALλ, LAMBDA(lbl,tId,csv,LAMBDA(x,CHOOSE(x,lbl,tId,csv))), EXPλ, LAMBDA(array,[rws],EXPAND(array,rws,9,"")), INCλ, LAMBDA(field3,field2,(field3=_rep)*(field2>=_beg)*(field2<=_end)), _fId, SEQUENCE(,9), _cId, VSTACK("1,2,3,4,,,5,13,14", "1,2,3,4,,6,5,10,11", "1,2,3,4,,,5,11,12", "1,2,3,4,6,,,8,9", "1,2,3,4,,,5,11,12", "1,2,3,4,7,6,5,12,13", "1,2,3,4,6,,5,14,15", "1,2,3,4,6,7,8,14,19"), REDUCE( EXPλ("Field"&_fId,2), FILTER(MAP(_lst,SEQUENCE(ROWS(_lst)),_cId,VALλ),_inc), LAMBDA(acc,val, LET( tbl, INDIRECT("tbl"&SUBSTITUTE(SUBSTITUTE(val(1)," ",),"-",)&"[#ALL]"), arr, SORTBY(EXPλ(CHOOSECOLS(tbl,--TEXTSPLIT(val(3),",",,1))),SORTBY(_fId,TEXTSPLIT(val(3),",")="")), bdy, DROP(arr,1), qry, FILTER(bdy,INCλ(CHOOSECOLS(bdy,3),CHOOSECOLS(bdy,2))), VSTACK(acc,EXPλ("["&val(2)&"] "&val(1)&":"),EXPλ(TAKE(arr,1)),EXPλ(IF(ISBLANK(qry),"",qry),ROWS(qry)+1)) ) ) ) ) ) )
I also added a 'FieldMap' worksheet to the attached revision, so you can see how the field mapping was generated (there are 4 formulas highlighted in blue, as well as a note showing the formula used as the Data Validation List Source for range C5:U12).
If you're still having issues applying these methods to your master workbook, I'm afraid there's not much more I can do to help aside from gaining access to your actual workbook to troubleshoot the problem.
Best of luck!
djclements - For some reason, my replies to specific messages aren't posting here. I tried my best to find a problem, but I can't see anything wrong with the references. The only thing that is different on the original compared to the dummy posted here is that the staff names were removed along with all but a few records in each review tab, plus there are some other tabs that were not included that aren't referenced anywhere. Could it be the other tabs? I'm stumped. It works in the one you sent, but not on the original.
It's not likely to be related to the other tabs/worksheets in your master workbook, as the formula is only referencing cells/ranges in the 'RESULTS' tab directly. The INDIRECT function is being used to reference tables in the workbook, but the syntax for this is the same as what was already working in your original sample workbook(s), so that wouldn't explain it.
I saw your comment on the previous thread, where you confirmed "The master workbook is named differently and contains more tabs than the redacted (included here) spreadsheet, but all of the table names and column headers are the same.", so there shouldn't be any issues when copying the formula over. However, I also noticed there was a bit of a struggle to get any of the suggested formulas on that thread to work, and a considerable amount of time was spent troubleshooting this. To transfer the formula from the sample workbook to your master workbook, highlight the entire formula from within the formula bar in the sample workbook and press Ctrl+C to copy, then select the destination cell in your master workbook, click into the formula bar (delete any previous formula, if applicable) and press Ctrl+V to paste.
#VALUE! errors can be difficult to track down, but it usually means there is an issue with one or more of the data types used. For example, =10+"text" will return this error because the addition operator is expecting two numbers (type 1) but received a text string (type 2). =TAKE(A1:A5,{3}) will also error because the rows argument is expecting a scalar (type 1) but received an array (type 64). I've reviewed my formula and don't see anything out of place. Even if there was, it wouldn't explain why the formula works in the sample workbook but not in the master workbook.
Having said that, I'm not really a fan of how the current "working" formula outputs the report. There's a different number of columns being selected from each table, and the field order is different between tables. The end result is a bit of a mess, where only the first 3 columns are identical across all 8 tables, and the rest are a mix-match of data types. This makes formatting dates virtually impossible, as fields like "Date Processed" and "Date Reconsidered" are appearing in the same columns as numeric fields like "PID" and "Issue Number".
Another option is to use something of a field-mapping table to link compatible fields and output them to the same column. For example:
=LET(
_rep, RESULTS!$A$2,
_beg, RESULTS!$B$2,
_end, RESULTS!$C$2,
_lst, RESULTS!$A$5:$A$12,
_inc, (RESULTS!$E$5:$E$12="EXCEED")+(RESULTS!$E$5:$E$12="NOT MET"),
IF(
NOT(OR(_inc)),
"[no records found]",
LET(
VALλ, LAMBDA(lbl,tId,csv,LAMBDA(x,CHOOSE(x,lbl,tId,csv))),
EXPλ, LAMBDA(array,[rws],EXPAND(array,rws,9,"")),
INCλ, LAMBDA(field3,field2,(field3=_rep)*(field2>=_beg)*(field2<=_end)),
_fId, SEQUENCE(,9),
_cId, VSTACK("1,2,3,4,,,5,13,14", "1,2,3,4,,5,6,10,11", "1,2,3,4,,,5,11,12", "1,2,3,4,5,,,7,8",
"1,2,3,4,,,5,11,12", "1,2,3,5,7,6,4,12,13", "1,2,3,4,5,,6,14,15", "1,2,3,4,5,6,7,13,18"),
REDUCE(
EXPλ("Field"&_fId,2),
FILTER(MAP(_lst,SEQUENCE(ROWS(_lst)),_cId,VALλ),_inc),
LAMBDA(acc,val,
LET(
tbl, INDIRECT("tbl"&SUBSTITUTE(SUBSTITUTE(val(1)," ",),"-",)&"[#ALL]"),
arr, SORTBY(EXPλ(CHOOSECOLS(tbl,--TEXTSPLIT(val(3),",",,1))),SORTBY(_fId,TEXTSPLIT(val(3),",")="")),
bdy, DROP(arr,1),
qry, FILTER(bdy,INCλ(CHOOSECOLS(bdy,3),CHOOSECOLS(bdy,2))),
VSTACK(acc,EXPλ("["&val(2)&"] "&val(1)&":"),EXPλ(TAKE(arr,1)),EXPλ(IF(ISBLANK(qry),"",qry),ROWS(qry)+1))
)
)
)
)
)
)
The width of the output array in this example is fixed (9 columns). _cId is where the field-mapping is set for each table, and arr is where the field-mapping is applied (using SORTBY-TEXTSPLIT). This will output numeric fields like "PID" and "Issue Number" in Field5, and all date fields in Field7, making them easier to format:
Furthermore, if you're always dealing with the same 8 tables, it's also possible to eliminate the INDIRECT function by utilizing a custom CHOOSE based lambda function to select each table as needed. For example:
=LET(
_rep, RESULTS!$A$2,
_beg, RESULTS!$B$2,
_end, RESULTS!$C$2,
_lst, RESULTS!$A$5:$A$12,
_inc, (RESULTS!$E$5:$E$12="EXCEED")+(RESULTS!$E$5:$E$12="NOT MET"),
IF(
NOT(OR(_inc)),
"[no records found]",
LET(
VALλ, LAMBDA(lbl,tId,csv,LAMBDA(x,CHOOSE(x,lbl,tId,csv))),
EXPλ, LAMBDA(array,[rws],EXPAND(array,rws,9,"")),
INCλ, LAMBDA(field3,field2,(field3=_rep)*(field2>=_beg)*(field2<=_end)),
TBLλ, LAMBDA(table_id,CHOOSE(table_id,
tblClaims[#All],tblMiscAssignments[#All],tblProcessProtest[#All],tblIDD[#All],
tblProcessAppeal[#All],tblDPU[#All],tblVetRRVDVOP[#All],tblRESEA[#All])),
_fId, SEQUENCE(,9),
_cId, VSTACK("1,2,3,4,,,5,13,14", "1,2,3,4,,5,6,10,11", "1,2,3,4,,,5,11,12", "1,2,3,4,5,,,7,8",
"1,2,3,4,,,5,11,12", "1,2,3,5,7,6,4,12,13", "1,2,3,4,5,,6,14,15", "1,2,3,4,5,6,7,13,18"),
REDUCE(
EXPλ("Field"&_fId,2),
FILTER(MAP(_lst,SEQUENCE(ROWS(_lst)),_cId,VALλ),_inc),
LAMBDA(acc,val,
LET(
tbl, TBLλ(val(2)),
arr, SORTBY(EXPλ(CHOOSECOLS(tbl,--TEXTSPLIT(val(3),",",,1))),SORTBY(_fId,TEXTSPLIT(val(3),",")="")),
bdy, DROP(arr,1),
qry, FILTER(bdy,INCλ(CHOOSECOLS(bdy,3),CHOOSECOLS(bdy,2))),
VSTACK(acc,EXPλ("["&val(2)&"] "&val(1)&":"),EXPλ(TAKE(arr,1)),EXPλ(IF(ISBLANK(qry),"",qry),ROWS(qry)+1))
)
)
)
)
)
)
TBLλ is the lambda function that contains the references to each table, and TBLλ(val(2)) is where each table is recalled (replacing the INDIRECT function). I've also used a custom VALλ function here to make referencing the variables easier (replacing the INDEX function).
Please note, many of the variables and functions used in these examples can be defined in Name Manager, which would make the end formula shorter and easier to write. However, I refrained from doing so to make it as easy as possible for you to transfer the formula to your master workbook. If you're still experiencing issues and want to send me a copy of your master workbook in a private message (go to my profile page and click "Message"), I'll be happy to troubleshoot it for you. Cheers!
- Marcus_BoothAug 20, 2025Iron Contributor
I think I found the problem. I forgot that I had moved one of the columns on the RRV/DVOP table to make the date columns line up better on the REPORT tab. I have now adjusted the SheetMap accordingly. Here is the corrected SheetMap. I'm really sorry about that. Would you mind a final adjustment to the formula that takes this into account? Please let me know if you would need anything else. Thank you!
- djclementsAug 22, 2025Bronze Contributor
Hi Marcus,
If the order of the table columns has changed, that could be causing some issues, although it may or may not be the source of the #VALUE! error. However, if the total number of columns in each table has changed, that could be the reason. For example, the SheetMap shows only 13 columns in the Claims table, whereas the sample file contains 14 columns, so using =CHOOSECOLS(tblClaims,14) will return #VALUE! if column 14 no longer exists (out of scope reference).
It would also be helpful if you could provide the column names (table headers) in the SheetMap (it currently only shows the column index numbers). Try using the following formula to generate a complete list, then Copy the results and Paste Special > Values into the SheetMap workbook:
=LET( i, SEQUENCE(SHEETS(Claims:RESEA!A1)), j, SEQUENCE(,COLUMNS(A1:Z1)), HSTACK(TOCOL(IF(j,i)),TOCOL(IF(i,j)),TOCOL(Claims:RESEA!A1:Z1)) )
Please include all results, even those that return 0's for fields that don't exist, so I'll be able to easily identify exactly what's been changed (number of columns, column names and order).
Kind regards.
- Marcus_BoothAug 22, 2025Iron Contributor
I found a lot of discrepancies. I fixed them and pointed things out best I could. Hopefully this will be able to work. Thank you for the help!
- Marcus_BoothAug 19, 2025Iron Contributor
Unfortunately, I'm still not able to get it to work. I'm not sure if this has any effect, but the person who assisted with this and got it working included a 'Sheet Map' for use in formatting the columns. I also re-arranged a couple of the columns on some of the workbooks in order to better line up the columns with same formatting requirements. I may just need to take some time to strip down what I have again and send one that is clean and redacted. Might take me a few days depending on how busy we are here. Thank you again for your assistance. If you have any other suggestions, please let me know. :)