Skip to content
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

Countifs fail to evaluate correctly #825

Closed
jamstar9506 opened this issue May 1, 2022 · 2 comments · Fixed by #1115
Closed

Countifs fail to evaluate correctly #825

jamstar9506 opened this issue May 1, 2022 · 2 comments · Fixed by #1115

Comments

@jamstar9506
Copy link

I am using NPOI 2.5.5 and found that using countifs in a cell, and evaluating the cell, I receive back the result of the lowest count matching criteria.

The following formulas evaluate to the same value when they should not as they get progressively more restrictive.

=COUNTIFS(Data!AL:AL,">0",Data!J:J,D3)
=COUNTIFS(Data!AM:AM,">0",Data!AL:AL,0,Data!J:J,D3)
=COUNTIFS(Data!AM:AM,0,Data!AL:AL,">0",Data!J:J,D3)

This is not the expected outcome countifs in Excel as they do evaluate differently when opened in excel.

https://github.com/nissl-lab/npoi/blob/master/main/SS/Formula/Functions/Countifs.cs

I checked the formula definition and found that it runs a countif with the each set of arguments and compares the value to see what one is smaller and tracks that. It will need to run a countif but track what rows are counted then only check those rows for the next arguments.

Please let me know if I can provide any other information.

@tonyqus
Copy link
Member

tonyqus commented May 29, 2022

I checked the formula definition from Microsoft document. Your concern makes sense.

Are you willing to create a PR to correct the logic of countifs?

@tonyqus tonyqus added the bug label May 29, 2022
@tonyqus tonyqus added this to the NPOI 2.6.0 milestone May 29, 2022
@tonyqus tonyqus modified the milestones: NPOI 2.6.0, NPOI 2.6.1 Jul 4, 2022
@jamstar9506
Copy link
Author

Hi tonyqus,

I have been busy but I should have some time to do it now. Do you have any insights on how to best accomplish this, or should I just go for it?

@tonyqus tonyqus modified the milestones: NPOI 2.6.1, NPOI 2.6.2 Feb 24, 2023
tonyqus added a commit that referenced this issue Jul 9, 2023
Countifs fail to evaluate correctly #825
@tonyqus tonyqus modified the milestones: NPOI 2.7.0, NPOI 2.6.2 Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants