Bug 65643 - FILTER function wrong number of arguments
Summary: FILTER function wrong number of arguments
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: SS Common (show other bugs)
Version: 5.0.0-FINAL
Hardware: PC Mac OS X 10.1
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-19 15:50 UTC by Raul Martin
Modified: 2021-10-22 13:35 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Raul Martin 2021-10-19 15:50:38 UTC
From Microsoft docs [1], FILTER function accepts between two and three arguments, such as:

=FILTER(A5:D20,C5:C20=H2,"")

However, in Apache POI the call 'FunctionMetadataRegistry.getFunctionByName("FILTER")' returns:


result = {FunctionMetadata@8544} "org.apache.poi.ss.formula.function.FunctionMetadata [447 FILTER]":
_index = 447
_name = "FILTER"
_minParams = 0
_maxParams = 0
_returnClassCode = 0
_parameterClassCodes = {byte[0]@10804}

Using the function as stated in Microsoft docs triggers a FormulaParseException with message
"Too many arguments to function 'FILTER'. Expected 0 but got 2."


[1]: https://support.microsoft.com/en-us/office/filter-function-f4f7cb66-82eb-4767-8f7c-4877ad80c759
Comment 1 PJ Fanning 2021-10-19 16:02:22 UTC
I don't think POI implements FILTER at all. Not every function is supported. If you would like to implement it yourself, that would be great.
Comment 2 PJ Fanning 2021-10-19 16:20:39 UTC
https://github.com/apache/poi/commit/616cdf944be2df447aaabd091dbbbff492472880 is a good example of how to add support for a missing function
Comment 3 PJ Fanning 2021-10-22 13:35:38 UTC
there does seem to be a bug in https://github.com/apache/poi/blob/trunk/poi/src/main/resources/org/apache/poi/ss/formula/function/functionMetadataCetab.txt - the FILTER function appears here but the definition seems to indicate that 0 args are expected