Skip to content

A function passed as an argument needs _xleta., so GROUPBY(…,SUM) computes #NAME? #617

Closed

Description

@ronistrom

What happens

The LAMBDA-helper functions can take a built-in function as an argument instead of a LAMBDA: GROUPBY(A2:A3,B2:B3,SUM), MAP(B2:B3,ABS). Excel stores that argument with a prefix of its own, _xleta.. hucre writes it bare. Even with #608 (which adds _xlfn. and _xlpm.), a file written with GROUPBY(A2:A3,B2:B3,SUM) opens without a prompt, but the cell computes #NAME?. With _xleta.SUM hand-edited in, it computes.

Expected

What Excel 16.114 for Mac saved when the bare formulas were typed in:

_xlfn.GROUPBY(A2:A3,B2:B3,_xleta.SUM)
_xlfn.PIVOTBY(A2:A3,A2:A3,B2:B3,_xleta.SUM)
_xlfn.BYROW(B2:B3,_xleta.SUM)
_xlfn.BYCOL(B2:B3,_xleta.MAX)
_xlfn.MAP(B2:B3,_xleta.ABS)
_xlfn.REDUCE(0,B2:B3,_xleta.SUM)
_xlfn.SCAN(0,B2:B3,_xleta.SUM)
_xlfn.MAKEARRAY(2,2,_xleta.PRODUCT)
_xlfn.GROUPBY(B2:B3,B2:B3,_xleta.PERCENTOF)   ← a future function gets only _xleta., no _xlfn.

Why it isn't a one-liner

_xleta. goes on a built-in function name used as a value. Telling SUM there apart from a defined name or a LAMBDA bound by LET (_xlpm.f) needs Excel's full list of built-in functions, which hucre doesn't have. The future-function list in formula-prefix.ts covers only the functions added after 2007.

Workaround

Pass a LAMBDA: GROUPBY(A2:A3,B2:B3,LAMBDA(x,SUM(x))). With #608, that's written as _xlfn.LAMBDA(_xlpm.x,SUM(_xlpm.x)), which Excel computes.

Where

src/xlsx/formula-prefix.ts (on the #608 branch until it merges). docs/PARITY.md on that branch already notes the gap.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions