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

MaxIfs/MinIfs returns #N/A for ">0" criteria #591

Closed
colbybhearn opened this issue Feb 8, 2022 · 2 comments
Closed

MaxIfs/MinIfs returns #N/A for ">0" criteria #591

colbybhearn opened this issue Feb 8, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@colbybhearn
Copy link
Contributor

I believe I'm seeing an issue with Maxifs and Minifs in EPPlus where they mistakenly return #N/A
In terms of the MS documentation (https://support.microsoft.com/en-us/office/minifs-function-6ca1ddaa-079b-4e74-80cc-72eef32e6599)

  • min_range is a range numbers,
  • criteria_range1 a range of numbers (same range as min_range), and
  • criteria is ">0"

Excel came up with the expected value. I tried rolling back to EPP 5.8.5 and 5.8.4, but neither behaved any better. I'm not seeing in GetMatches() where the > operator is supported, but I could be missing that. Hopefully this is a simple fix!

Here are two complete examples by which you can reproduce this:

A) Additional unit test for MinAndMaxIfsTests.cs
Method:

        [TestMethod]
        public void MinIfsShouldWork()
        {
            _worksheet.Cells["F1"].Formula = "MAXIFS(D3:D7, D3:D7,\">0\")";
            _worksheet.Calculate();
            Assert.AreEqual(93d, _worksheet.Cells["F1"].Value);
        }

Output: (yes, 93 should be 93d, but that's irrelevant)
image

B) standalone test code
Code:

        ExcelPackage.LicenseContext = LicenseContext.Commercial;
        string path = @".\Minifs.xlsx";
        using (var package = new ExcelPackage(new FileInfo(path)))
        {
            ExcelWorksheet est = package.Workbook.Worksheets["Sheet1"];
            trace(est.Cells["F4"]);
            package.Workbook.Calculate();
            trace(est.Cells["F4"]);
            Console.WriteLine("");
        }

        public static void trace(ExcelRange c)
        {
            if(c.Value == null)
                System.Diagnostics.Trace.WriteLine($"{c.Address.ToString()} is null");
            else
                System.Diagnostics.Trace.WriteLine(c.Address.ToString() +"\t" +c.Formula + "\t" + c.Value.ToString());
        }

Input File: Minifs.xlsx
image

Output:

F4	_xlfn.MAXIFS(Values,Values,">0")	89
F4	_xlfn.MAXIFS(Values,Values,">0")	#N/A

Thank you.
-Colby

@swmal
Copy link
Contributor

swmal commented Feb 9, 2022

Thanks Colby, we'll have a look at this.

@swmal swmal self-assigned this Feb 9, 2022
@swmal swmal added the bug Something isn't working label Feb 9, 2022
@swmal
Copy link
Contributor

swmal commented Feb 11, 2022

This should be fixed now, and can be tested via our developerment nuget feed: https://github.com/EPPlusSoftware/EPPlus/wiki/Using-our-Develop-Nuget-Feed
Will be included in the next release.

Thank you for a very detailed description and code to replicate the issue.

/Mats

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants