-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AVERAGEIF / SUMIF only works for a couple cases #44
Comments
Don't forget about COUNTIF ... and AVERAGEIFS... and SUMIFS..... I affectionately refer to them as the IF and *IFS functions -- hey I should call them the *IF functions ... or would *IF? be appropriate? There are alot of issues with evaluating a criteria expression. You found some of them :) The main issue is that the expression is being evaluated as javascript ... but, it's not javascript. For example, Excel uses '<>' for not equals, but js uses '!='. And, js requires strings to be enclosed in quotes, but the excel expression does not use quotes. In excel, an expression of ='blah' will match the text 'blah' ... with the leading/trailing quotes. Of course Excel never uses single quotes anyway ... and there's no way to escape a quote so it's not possible to write something like "=""x"". Also, the excel expression doesn't support operators like add (+) and concat (&). For example, if the expression is =1+2, then excel matches on the string 1+2 ... not 3 which the js evaluator does. And on and on... Thing is the excel expression is much simpler than a js expression. The syntax includes the comparison operators (=, <>, <, <=, >, >=) ... and that's it. Well, there is some magic converting value types ... but that's it. I just implemented (custom code) to evaluate the criteria expression in a branch I'm working on ... trudb. A few dozen lines ... nothing big. This morning I was working on implementing wildcard matching, but I didn't finish it. I'll work on it again later. As for accepting non-range values: you are right that the excel function does not work with literal values. But, this library doesn't support ranges. So, either we allow these functions to operate on non-ranges, or exclude the functions altogether. I think there is some utility in including them even though they don't work like excel in this one respect. |
Is this going to be fixed or addressed in any way? |
I noticed the following issues with AVERAGEIF and SUMIF not behaving like the implementation in Excel:
Given this example spreadsheet...
...here's the result of some formulas we could write:
=AVERAGEIF(A1:A2, '>0')
=AVERAGEIF(A1:A2, '1')
=AVERAGEIF(A3:A4, 'yes')
A few notes:
The text was updated successfully, but these errors were encountered: