Note: The other languages of the website are Google-translated. Back to English
Log in  \/ 
x
or
x
Register  \/ 
x

or

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

Would you like to complete your daily work quickly and perfectly? Kutools for Excel brings 300 powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) and save 80% time for you.

  • Designed for 1500 work scenarios, helps you solve 80% Excel problems.
  • Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands.
  • Become an Excel expert in 3 minutes. No longer need to remember any painful formulas and VBA codes.
  • 30-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years.
Ribbon of Excel (with Kutools for Excel installed)

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, Firefox, And New Internet Explorer.
Screen Shot of Excel (with Office Tab installed)
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.