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

SUMIFS multiple dimensions #2061

Merged
merged 4 commits into from Apr 14, 2023

Conversation

igitur
Copy link
Member

@igitur igitur commented Apr 12, 2023

Fixes #2041

Add support and applicable errors for input ranges having multilpe dimensions (more than 1 column)

@igitur igitur requested a review from jahav April 12, 2023 18:13
Copy link
Member

@jahav jahav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks for investigating, good work.

I wonder about other functions, SUMIF has a sibling functions AVERAGEIF/S and COUNTIF/S. We don't implement AVERAGEIF, but COUNTIF has a similar problem.

I think that rather than fixing old range functions, it would be better to reimplement them. The XObjectExpression adapter works, but I would like to remove it.

It would require a new method to validate criteria (outlined here).

/// </summary>
/// <param name="rangeExpression">Expression referring to the cell range.</param>
/// <returns>A tuple of column and row counts.</returns>
internal static (int columnCount, int rowCount) GetRangeDimensions(XObjectExpression rangeExpression)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Names of properties of named tuples should be in PascalCase.

@@ -2063,6 +2063,17 @@ public void SumIfs_ReturnsCorrectValues_ReferenceExampleForSumIf1FromMicrosoft(i
}
}

[Test]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Test] is not required if there is a [TestCase]

@@ -1783,6 +1782,26 @@ public void SumDateTimeAndNumber()
}
}

[Test]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Test] is not required if there is a [TestCase]

@igitur igitur force-pushed the issue2041-sumifs-multi-dimensions branch from 909b54d to 38862f1 Compare April 14, 2023 09:22
@igitur
Copy link
Member Author

igitur commented Apr 14, 2023

I wonder about other functions, SUMIF has a sibling functions AVERAGEIF/S and COUNTIF/S. We don't implement AVERAGEIF, but COUNTIF has a similar problem.

I can have a look at the sibling functions and fix them as a short-term goal.

I think that rather than fixing old range functions, it would be better to reimplement them. The XObjectExpression adapter works, but I would like to remove it.

It would require a new method to validate criteria (outlined here).

Don't think I have the capacity for that now, sorry. Hence the goal of this PR is a short term fix.

@jahav jahav added this to the v0.102 milestone Apr 14, 2023
@jahav jahav merged commit 9f36692 into ClosedXML:develop Apr 14, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SUMIF doesn't consider only first column
2 participants