Count rows if meet internal criteria in Excel

Supposing, you have a report of product sales of this year and last year, and now, you may need to count products where the sales in this year are greater than last year, or the sales in this year are less than last year as below screenshot shown. Normally, you can add a helper column for calculating the sale difference between the two years, and then use COUNTIF to get result. But, this article, I will introduce the SUMPRODUCT function to get the result directly without any helper column.

Count rows if meet internal criteria with SUMPRODUCT function/a>

Count rows if meet internal criteria with SUMPRODUCT function

To count the rows if meet internal, calculated criteria, the SUMPRODUCT function in Excel may help you, the generic syntax is:

=SUMPRODUCT(--(logical_expression))
• logical_expression: It is used to compare the values in a row or column.

1. To get the number of products that sales increased, please enter the below formula into a blank cell:

=SUMPRODUCT(--(B2:B8<C2:C8))

To get the number of products that sales decreased, please apply the following formula:

=SUMPRODUCT(--(B2:B8>C2:C8))

Note: In the above formula, B2:B8<C2:C8, B2:B8>C2:C8 are logical expressions which used to compare the values in column B to the values in column C.

2. And then, press Enter key to get the result you need, see screenshot:

Explanation of the formula:

=SUMPRODUCT(--(B2:B8<C2:C8))

• B2:B8<C2:C8: This logical expression is used to compare the values in column B to the values in column C in each row, and returns the array values as this: {TRUE;FALSE;TRUE;TRUE;FALSE;TRUE;TRUE}.
• --(B2:B8<C2:C8)=--({TRUE;FALSE;TRUE;TRUE;FALSE;TRUE;TRUE}): --this double negative sign is used to convert TRUE value to 1 and False value to 0. So, you will get the result as this: {1;0;1;1;0;1;1}.
• SUMPRODUCT(--(B2:B8<C2:C8))=SUMPRODUCT({1;0;1;1;0;1;1}): This SUMPRODUCT function sums all the items in the array, and return the result: 5.

Relative function used:

• SUMPRODUCT:
• The SUMPRODUCT function can be used to multiply two or more columns or arrays together, and then get the sum of products.

More articles:

• Count rows if meet multiple criteria
• Count the number of rows in a range based on multiple criteria, some of which depends on the logical tests that work at the row-level, the SUMPRODUCT function in Excel may do you a favor.
• Count Matches Between Two Columns
• For example, I have two lists of data in column A and column C, now, I want to compare the two columns and count if the value in column A found in column C in the same row as below screenshot shown. In this case, the SUMPRODUCT function may be the best function for you to solve this task in Excel.
• Count Number Of Cells That Contain Specific Text
• Supposing, you have a list of text strings, and may want to find the number of cells that contain certain text as part of their contents. In this case, you can use the wildcard characters (*) that represents any texts or characters in your criteria when applying the COUNTIF function. This article, I will introduce how to use formulas for dealing with this job in Excel.

The Best Office Productivity Tools

Kutools for Excel - Helps You To Stand Out From Crowd

 ðŸ¤– Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functionsâ€¦ Popular Features: Find, Highlight or Identify Duplicates  |  Delete Blank Rows  |  Combine Columns or Cells without Losing Data  |  Round without Formula ... Super VLookup: Multiple Criteria  |  Multiple Value  |  Across Multi-Sheets  |  Fuzzy Lookup... Adv. Drop-down List: Easy Drop Down List  |  Dependent Drop Down List  |  Multi-select Drop Down List... Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Columns to Select Same & Different Cells ... Featured Features: Grid Focus  |  Design View  |  Big Formula Bar  |  Workbook & Sheet Manager | Resource Library (Auto Text)  |  Date Picker  |  Combine Worksheets  |  Encrypt/Decrypt Cells  |  Send Emails by List  |  Super Filter  |  Special Filter (filter bold/italic/strikethrough...) ... Top 15 Toolsets:  12 Text Tools (Add Text, Remove Characters ...)  |  50+ Chart Types (Gantt Chart ...)  |  40+ Practical Formulas (Calculate age based on birthday ...)  |  19 Insertion Tools (Insert QR Code, Insert Picture from Path ...)  |  12 Conversion Tools (Numbers to Words, Currency Conversion ...)  |  7 Merge & Split Tools (Advanced Combine Rows, Split Excel Cells ...)  |  ... and more

Kutools for Excel Boasts Over 300 Features, Ensuring That What You Need is Just A Click Away...

Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)

• One second to switch between dozens of open documents!
• Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
• Increases your productivity by 50% when viewing and editing multiple documents.
• Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Edge and Firefox.