Count not sum in excel

A colleague of mine has an exel file, on one sheet on a few columns when you select multiple cells it shows the sum, but the problem is that on other column it only shows count and not sum.

Any idea why?

asked Oct 11, 2018 at 8:29

Remus Rigo's user avatar

5

The data (atleast in that column) has been copied from a source which is delimited. Hence that column is delimited text. To rectify, select the whole column at the top and then on the ribbon, click on Data-> Text to column and then select delimited (not fixed width) in the appearing window, click next, select tab (normally default), select next and then finish.

It will convert the data to numbers.

answered Jul 20, 2019 at 14:21

bharatlohiya's user avatar

Counting is an integral part of data analysis, whether you are tallying the head count of a department in your organization or the number of units that were sold quarter-by-quarter. Excel provides multiple techniques that you can use to count cells, rows, or columns of data. To help you make the best choice, this article provides a comprehensive summary of methods, a downloadable workbook with interactive examples, and links to related topics for further understanding.

Download our examples

You can download an example workbook that gives examples to supplement the information in this article. Most sections in this article will refer to the appropriate worksheet within the example workbook that provides examples and more information.

Download examples to count values in a spreadsheet

In this article

  • Simple counting

    • Use AutoSum

    • Add a Subtotal row

    • Count cells in a list or Excel table column by using the SUBTOTAL function

  • Counting based on one or more conditions

    • Video: Use the COUNT, COUNTIF, and COUNTA functions

    • Count cells in a range by using the COUNT function

    • Count cells in a range based on a single condition by using the COUNTIF function

    • Count cells in a column based on single or multiple conditions by using the DCOUNT function

    • Count cells in a range based on multiple conditions by using the COUNTIFS function

    • Count based on criteria by using the COUNT and IF functions together

    • Count how often multiple text or number values occur by using the SUM and IF functions together

    • Count cells in a column or row in a PivotTable

  • Counting when your data contains blank values

    • Count nonblank cells in a range by using the COUNTA function

    • Count nonblank cells in a list with specific conditions by using the DCOUNTA function

    • Count blank cells in a contiguous range by using the COUNTBLANK function

    • Count blank cells in a non-contiguous range by using a combination of SUM and IF functions

  • Counting unique occurrences of values

    • Count the number of unique values in a list column by using Advanced Filter

    • Count the number of unique values in a range that meet one or more conditions by using IF, SUM, FREQUENCY, MATCH, and LEN functions

  • Special cases (count all cells, count words)

    • Count the total number of cells in a range by using ROWS and COLUMNS functions

    • Count words in a range by using a combination of SUM, IF, LEN, TRIM, and SUBSTITUTE functions

  • Displaying calculations and counts on the status bar

Simple counting

You can count the number of values in a range or table by using a simple formula, clicking a button, or by using a worksheet function.

Excel can also display the count of the number of selected cells on the Excel status bar. See the video demo that follows for a quick look at using the status bar. Also, see the section Displaying calculations and counts on the status bar for more information. You can refer to the values shown on the status bar when you want a quick glance at your data and don’t have time to enter formulas.

Video: Count cells by using the Excel status bar

Watch the following video to learn how to view count on the status bar.

Your browser does not support video. Install Microsoft Silverlight, Adobe Flash Player, or Internet Explorer 9.

Use AutoSum

Use AutoSum by selecting a range of cells that contains at least one numeric value. Then on the Formulas tab, click AutoSum > Count Numbers.

Count Numbers

Excel returns the count of the numeric values in the range in a cell adjacent to the range you selected. Generally, this result is displayed in a cell to the right for a horizontal range or in a cell below for a vertical range.

Top of Page

Add a Subtotal row

You can add a subtotal row to your Excel data. Click anywhere inside your data, and then click Data > Subtotal.

Note: The Subtotal option will only work on normal Excel data, and not Excel tables, PivotTables, or PivotCharts.

Click Subtotal in the Data tab to add a subtotal row in your Excel Data

Also, refer to the following articles:

  • Outline (group) data in a worksheet

  • Insert subtotals in a list of data in a worksheet

Top of Page

Count cells in a list or Excel table column by using the SUBTOTAL function

Use the SUBTOTAL function to count the number of values in an Excel table or range of cells. If the table or range contains hidden cells, you can use SUBTOTAL to include or exclude those hidden cells, and this is the biggest difference between SUM and SUBTOTAL functions.

The SUBTOTAL syntax goes like this:

SUBTOTAL(function_num,ref1,[ref2],…)

SUBTOTAL example

To include hidden values in your range, you should set the function_num argument to 2.

To exclude hidden values in your range, set the function_num argument to 102.

Top of Page

Counting based on one or more conditions

You can count the number of cells in a range that meet conditions (also known as criteria) that you specify by using a number of worksheet functions.

Video: Use the COUNT, COUNTIF, and COUNTA functions

Watch the following video to see how to use the COUNT function and how to use the COUNTIF and COUNTA functions to count only the cells that meet conditions you specify.

Your browser does not support video. Install Microsoft Silverlight, Adobe Flash Player, or Internet Explorer 9.

Top of Page

Count cells in a range by using the COUNT function

Use the COUNT function in a formula to count the number of numeric values in a range.

An example of COUNT function

In the above example, A2, A3, and A6 are the only cells that contains numeric values in the range, hence the output is 3.

Note: A7 is a time value, but it contains text (a.m.), hence COUNT does not consider it a numerical value. If you were to remove a.m. from the cell, COUNT will consider A7 as a numerical value, and change the output to 4.

Top of Page

Count cells in a range based on a single condition by using the COUNTIF function

Use the COUNTIF function function to count how many times a particular value appears in a range of cells.

COUNTIF examples

Top of Page

Count cells in a column based on single or multiple conditions by using the DCOUNT function

DCOUNT function counts the cells that contain numbers in a field (column) of records in a list or database that match conditions that you specify.

In the following example, you want to find the count of the months including or later than March 2016 that had more than 400 units sold. The first table in the worksheet, from A1 to B7, contains the sales data.

Sample data for DCOUNT

DCOUNT uses conditions to determine where the values should be returned from. Conditions are typically entered in cells in the worksheet itself, and you then refer to these cells in the criteria argument. In this example, cells A10 and B10 contain two conditions—one that specifies that the return value must be greater than 400, and the other that specifies that the ending month should be equal to or greater than March 31st, 2016.

You should use the following syntax:

=DCOUNT(A1:B7,»Month ending»,A9:B10)

DCOUNT checks the data in the range A1 through B7, applies the conditions specified in A10 and B10, and returns 2, the total number of rows that satisfy both conditions (rows 5 and 7).

Top of Page

Count cells in a range based on multiple conditions by using the COUNTIFS function

The COUNTIFS function is similar to the COUNTIF function with one important exception: COUNTIFS lets you apply criteria to cells across multiple ranges and counts the number of times all criteria are met. You can use up to 127 range/criteria pairs with COUNTIFS.

The syntax for COUNTIFS is:

COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2],…)

See the following example:

COUNTIFS example

Top of Page

Count based on criteria by using the COUNT and IF functions together

Let’s say you need to determine how many salespeople sold a particular item in a certain region or you want to know how many sales over a certain value were made by a particular salesperson. You can use the IF and COUNT functions together; that is, you first use the IF function to test a condition and then, only if the result of the IF function is True, you use the COUNT function to count cells.

Notes: 

  • The formulas in this example must be entered as array formulas. If you have opened this workbook in Excel for Windows or Excel 2016 for Mac and want to change the formula or create a similar formula, press F2, and then press Ctrl+Shift+Enter to make the formula return the results you expect. In earlier versions of Excel for Mac, use The Command button. +Shift+Enter.

  • For the example formulas to work, the second argument for the IF function must be a number.

Examples of nested COUNT and IF functions

Top of Page

Count how often multiple text or number values occur by using the SUM and IF functions together

In the examples that follow, we use the IF and SUM functions together. The IF function first tests the values in some cells and then, if the result of the test is True, SUM totals those values that pass the test.

Example 1

Example 1: SUM and IF nested in a formula

The above function says if C2:C7 contains the values Buchanan and Dodsworth, then the SUM function should display the sum of records where the condition is met. The formula finds three records for Buchanan and one for Dodsworth in the given range, and displays 4.

Example 2

Example 2: SUM and IF nested in a formula

The above function says if D2:D7 contains values lesser than $9000 or greater than $19,000, then SUM should display the sum of all those records where the condition is met. The formula finds two records D3 and D5 with values lesser than $9000, and then D4 and D6 with values greater than $19,000, and displays 4.

Example 3

Example 3: SUM and IF nested in a formula

The above function says if D2:D7 has invoices for Buchanan for less than $9000, then SUM should display the sum of records where the condition is met. The formula finds that C6 meets the condition, and displays 1.

Important: The formulas in this example must be entered as array formulas. That means you press F2 and then press Ctrl+Shift+Enter. In earlier versions of Excel for Mac use The Command button.+Shift+Enter.

See the following Knowledge Base articles for additional tips:

  • XL: Using SUM(IF()) As an Array Function Instead of COUNTIF() with AND

  • XL: How to Count the Occurrences of a Number or Text in a Range

Top of Page

Count cells in a column or row in a PivotTable

A PivotTable summarizes your data and helps you analyze and drill down into your data by letting you choose the categories on which you want to view your data.

You can quickly create a PivotTable by selecting a cell in a range of data or Excel table and then, on the Insert tab, in the Tables group, clicking PivotTable.

Example of a PivotTable and how the Fields correlate to the Fields list.

Let’s look at a sample scenario of a Sales spreadsheet, where you can count how many sales values are there for Golf and Tennis for specific quarters.

Note: For an interactive experience, you can run these steps on the sample data provided in the PivotTable sheet in the downloadable workbook.

  1. Enter the following data in an Excel spreadsheet.

    Sample data for PivotTable

  2. Select A2:C8

  3. Click Insert > PivotTable.

  4. In the Create PivotTable dialog box, click Select a table or range, then click New Worksheet, and then click OK.

    An empty PivotTable is created in a new sheet.

  5. In the PivotTable Fields pane, do the following:

    1. Drag Sport to the Rows area.

    2. Drag Quarter to the Columns area.

    3. Drag Sales to the Values area.

    4. Repeat step c.

      The field name displays as SumofSales2 in both the PivotTable and the Values area.

      At this point, the PivotTable Fields pane looks like this:

      PivotTable Fields

    5. In the Values area, click the dropdown next to SumofSales2 and select Value Field Settings.

    6. In the Value Field Settings dialog box, do the following:

      1. In the Summarize value field by section, select Count.

      2. In the Custom Name field, modify the name to Count.

        Value Field Settings dialog box

      3. Click OK.

    The PivotTable displays the count of records for Golf and Tennis in Quarter 3 and Quarter 4, along with the sales figures.

    PivotTable

Top of Page

Counting when your data contains blank values

You can count cells that either contain data or are blank by using worksheet functions.

Count nonblank cells in a range by using the COUNTA function

Use the COUNTA function function to count only cells in a range that contain values.

When you count cells, sometimes you want to ignore any blank cells because only cells with values are meaningful to you. For example, you want to count the total number of salespeople who made a sale (column D).

An example of COUNTA

COUNTA ignores the blank values in D3, D4, D8, and D11, and counts only the cells containing values in column D. The function finds six cells in column D containing values and displays 6 as the output.

Top of Page

Count nonblank cells in a list with specific conditions by using the DCOUNTA function

Use the DCOUNTA function to count nonblank cells in a column of records in a list or database that match conditions that you specify.

The following example uses the DCOUNTA function to count the number of records in the database that is contained in the range A1:B7 that meet the conditions specified in the criteria range A9:B10. Those conditions are that the Product ID value must be greater than or equal to 2000 and the Ratings value must be greater than or equal to 50.

An example of DCOUNTA function

DCOUNTA finds two rows that meet the conditions- rows 2 and 4, and displays the value 2 as the output.

Top of Page

Count blank cells in a contiguous range by using the COUNTBLANK function

Use the COUNTBLANK function function to return the number of blank cells in a contiguous range (cells are contiguous if they are all connected in an unbroken sequence). If a cell contains a formula that returns empty text («»), that cell is counted.

When you count cells, there may be times when you want to include blank cells because they are meaningful to you. In the following example of a grocery sales spreadsheet. suppose you want to find out how many cells don’t have the sales figures mentioned.

An example of COUNTBLANK

Note: The COUNTBLANK worksheet function provides the most convenient method for determining the number of blank cells in a range, but it doesn’t work very well when the cells of interest are in a closed workbook or when they do not form a contiguous range. The Knowledge Base article XL: When to Use SUM(IF()) instead of CountBlank() shows you how to use a SUM(IF()) array formula in those cases.

Top of Page

Count blank cells in a non-contiguous range by using a combination of SUM and IF functions

Use a combination of the SUM function and the IF function. In general, you do this by using the IF function in an array formula to determine whether each referenced cell contains a value, and then summing the number of FALSE values returned by the formula.

See a few examples of SUM and IF function combinations in an earlier section Count how often multiple text or number values occur by using the SUM and IF functions together in this topic.

Top of Page

Counting unique occurrences of values

You can count unique values in a range by using a PivotTable, COUNTIF function, SUM and IF functions together, or the Advanced Filter dialog box.

Count the number of unique values in a list column by using Advanced Filter

Use the Advanced Filter dialog box to find the unique values in a column of data. You can either filter the values in place or you can extract and paste them to a new location. Then you can use the ROWS function to count the number of items in the new range.

To use Advanced Filter, click the Data tab, and in the Sort & Filter group, click Advanced.

The following figure shows how you use the Advanced Filter to copy only the unique records to a new location on the worksheet.

Advanced Filter

In the following figure, column E contains the values that were copied from the range in column D.

A column copied from another location

Notes: 

  • If you filter your data in place, values are not deleted from your worksheet — one or more rows might be hidden. Click Clear in the Sort & Filter group on the Data tab to display those values again.

  • If you only want to see the number of unique values at a quick glance, select the data after you have used the Advanced Filter (either the filtered or the copied data) and then look at the status bar. The Count value on the status bar should equal the number of unique values.

For more information, see Filter by using advanced criteria

Top of Page

Count the number of unique values in a range that meet one or more conditions by using IF, SUM, FREQUENCY, MATCH, and LEN functions

Use various combinations of the IF, SUM, FREQUENCY, MATCH, and LEN functions.

For more information and examples, see the section «Count the number of unique values by using functions» in the article Count unique values among duplicates.

Top of Page

Special cases (count all cells, count words)

You can count the number of cells or the number of words in a range by using various combinations of worksheet functions.

Count the total number of cells in a range by using ROWS and COLUMNS functions

Suppose you want to determine the size of a large worksheet to decide whether to use manual or automatic calculation in your workbook. To count all the cells in a range, use a formula that multiplies the return values using the ROWS and COLUMNS functions. See the following image for an example:

Example of ROWS and COLUMNS function to count the number of cells in a range

Top of Page

Count words in a range by using a combination of SUM, IF, LEN, TRIM, and SUBSTITUTE functions

You can use a combination of the SUM, IF, LEN, TRIM, and SUBSTITUTE functions in an array formula. The following example shows the result of using a nested formula to find the number of words in a range of 7 cells (3 of which are empty). Some of the cells contain leading or trailing spaces — the TRIM and SUBSTITUTE functions remove these extra spaces before any counting occurs. See the following example:

Example of a nested formula to count words

Now, for the above formula to work correctly, you have to make this an array formula, otherwise the formula returns the #VALUE! error. To do that, click on the cell that has the formula, and then in the Formula bar, press Ctrl + Shift + Enter. Excel adds a curly bracket at the beginning and the end of the formula, thus making it an array formula.

For more information on array formulas, see Overview of formulas in Excel and Create an array formula.

Top of Page

Displaying calculations and counts on the status bar

When one or more cells are selected, information about the data in those cells is displayed on the Excel status bar. For example, if four cells on your worksheet are selected, and they contain the values 2, 3, a text string (such as «cloud»), and 4, all of the following values can be displayed on the status bar at the same time: Average, Count, Numerical Count, Min, Max, and Sum. Right-click the status bar to show or hide any or all of these values. These values are shown in the illustration that follows.

Status bar

Top of Page

Need more help?

You can always ask an expert in the Excel Tech Community or get support in the Answers community.

Count | Countif | Countifs | Sum | Sumif | Sumifs

The most used functions in Excel are the functions that count and sum. You can count and sum based on one criteria or multiple criteria.

Count

To count the number of cells that contain numbers, use the COUNT function.

Count Function

Note: to count blank and nonblank cells in Excel, use COUNTBLANK and COUNTA.

Countif

To count cells based on one criteria (for example, greater than 9), use the following COUNTIF function.

Countif Function

Note: visit our page about the COUNTIF function for many more examples.

Countifs

To count rows based on multiple criteria (for example, green and greater than 9), use the following COUNTIFS function.

Countifs Function

Sum

To sum a range of cells, use the SUM function.

Sum Function

Note: visit our page about the SUM function for many more examples.

Sumif

To sum cells based on one criteria (for example, greater than 9), use the following SUMIF function (two arguments).

Sumif Function, Two Arguments

To sum cells based on one criteria (for example, green), use the following SUMIF function (three arguments, last argument is the range to sum).

Sumif Function, Three Arguments

Note: visit our page about the SUMIF function for many more examples.

Sumifs

To sum cells based on multiple criteria (for example, circle and red), use the following SUMIFS function (first argument is the range to sum).

Sumifs Function

General note: in a similar way, you can use the AVERAGEIF function to average cells based on one criteria and the AVERAGEIFS function to average cells based on multiple criteria.

check
Best Answer

  • Author Greg Bond

    Are you referring to a function you entered into a cell, or are you referring to Excel’s status bar info?

    Image: post contentImage: post content

    If status bar, you can right click on this area to change what is displayed there.


    Was this post helpful?
    thumb_up
    thumb_down

  • View Best Answer in replies below

    4 Replies

    • Author Bud G.

      Bud G.


      This person is a Verified Professional

      This person is a verified professional.

      Verify your account
      to enable IT peers to see that you are a professional.

      mace

      Are the calculations part of a pivot table?


      Was this post helpful?
      thumb_up
      thumb_down

    • Author Dawn Felix

      Yes it is.Its for a manufacturing company.  I’m not a excel user so this is new for me. The spreadsheet used to be able to select fields in a column and it would give you the totals now it just counts.  I checked the option settings and it’s on automatic calculation. Something happen when I opened it in Excel 2003? any ideas?


      Was this post helpful?
      thumb_up
      thumb_down

    • Author Greg Bond

      Are you referring to a function you entered into a cell, or are you referring to Excel’s status bar info?

      Image: post contentImage: post content

      If status bar, you can right click on this area to change what is displayed there.


      Was this post helpful?
      thumb_up
      thumb_down

    • Author Dawn Felix

      Well all I had to do was to go into the status bar and choose what I wanted the excel speadsheet to do.

      Many Thanks!

      Dawn

      Excel newbie:)


      Was this post helpful?
      thumb_up
      thumb_down

    In this example, the goal is to get a count of people that hold shares in whole numbers. For example, Bob holds 100 shares (even), so he should be included in the whole number count, while Cindy holds 50.5 shares, so she should not be included in the whole number count.

    The first problem is how to determine whole numbers. This can be done with the INT, TRUNC, or MOD functions as explained in detail here. In this example shown above, we are using the MOD function option:

    =MOD(A1,1)=0 // TRUE for whole numbers
    

    Now that we know how to test for a whole number, how can we use this approach to get a count of whole numbers? You might at first be tempted to use the COUNTIF or COUNTIFS functions. However, these functions won’t let you use an array* in place of the range argument, so COUNTIF won’t work:

    =COUNTIF(MOD(shares,1),0) // won't work!
    

    * MOD(shares,1) is technically an array operation that returns an array of values. See this article for more information about limitations in COUNTIF, SUMIF, etc.

    Instead, we need a way to work with the array directly with Boolean logic. Boolean logic is a technique for building formulas that take advantage of the fact that TRUE = 1, and FALSE = 0 in math operations.  In the example shown, this is what the formula in G5 does:

    =SUMPRODUCT(--(MOD(shares,1)=0))
    

    Working from the inside out, we first run all values through the MOD test shown above:

    =MOD(shares,1)=0 // test all values
    

    Because there are eleven values in shares (C5:C15), we get eleven results in an array like this:

    {TRUE;FALSE;FALSE;TRUE;TRUE;TRUE;TRUE;FALSE;FALSE;TRUE;TRUE}
    

    In this array, TRUE values represent a whole number, and FALSE values represent a decimal number. Next, we need to convert the TRUE and FALSE values to 1s and 0s. To do this, we use a double-negative (—):

    --{TRUE;FALSE;FALSE;TRUE;TRUE;TRUE;TRUE;FALSE;FALSE;TRUE;TRUE}
    

    This operation returns a numeric array composed only of 1s and 0s:

    {1;0;0;1;1;1;1;0;0;1;1}
    

    This is exactly what we need to count whole numbers. This array is returned directly to the SUMPRODUCT function:

    =SUMPRODUCT({1;0;0;1;1;1;1;0;0;1;1}) // returns 7
    

    With just one array to process, SUMPRODUCT returns the sum of all items in the array, 7, which is the count of whole numbers in the range C5:C15.

    Count decimal values

    To change the formula to count numbers with decimal values, we only need to change the logical operator in the MOD snippet from an equal sign (=) to the not equal to (<>) operator. The formula in G6:

    =SUMPRODUCT(--(MOD(shares,1)<>0)) // returns 4
    

    Note the only change to the formula is the logical operator.

    Sum whole number shares

    To sum whole numbers only, we need to extend the formula a bit by multiplying the Boolean array explained above by the values in the named range shares. The formula in H5 calculates the total number of shares in the whole number group:

    =SUMPRODUCT(--(MOD(shares,1)=0)*shares)
    

    Notice the formula is almost the same as above. The result is that the zero values effectively cancel out the shares in the decimal group:

    =SUMPRODUCT(--(MOD(shares,1)=0)*shares)
    =SUMPRODUCT({1;0;0;1;1;1;1;0;0;1;1}*{100;50.5;110.75;25;50;75;50;60.25;120.75;100;50})
    =SUMPRODUCT({100;0;0;25;50;75;50;0;0;100;50})
    =450
    

    Sum whole number share values

    To sum the values associated with whole number shares, we need to adjust the formula again. This time instead of multiplying the Boolean array by shares, we multiply by value. The formula in I5 is:

    =SUMPRODUCT(--(MOD(shares,1)=0)*value)
    

    The formula is solved in exactly the same way:

    =SUMPRODUCT(--(MOD(shares,1)=0)*value)
    =SUMPRODUCT({1;0;0;1;1;1;1;0;0;1;1}*{2500;1262.5;2768.75;625;1250;1875;1250;1506.25;3018.75;2500;1250})
    =SUMPRODUCT({2500;0;0;625;1250;1875;1250;0;0;2500;1250})
    =11250
    

    As above, the zero values in the Boolean array cancel out values for non-whole number shares, and the final result returned by SUMPRODUCT is 11250.

    SUM or SUMPRODUCT?

    Why are we using SUMPRODUCT and not the SUM function? It’s a good question.

    In older versions of Excel (anything but Excel 365) the same formula with SUM works, but must be entered as an array formula with Control + Shift + Enter. In Excel 365, SUM will just work, since Excel 365 handles arrays natively. Using SUMPRODUCT ensures that the formula will work in all versions of Excel without requiring Control + Shift + Enter. For more details, see Why SUMPRODUCT?

    Понравилась статья? Поделить с друзьями:
  • Count names in excel sheet
  • Count look and trace the correct word
  • Count lines of text in word
  • Count line number in word
  • Count letters in word python