In this example, the goal is to calculate a count and percentage for each category shown in column B. For convenience, the category values in column B are in the named rangecategory (B5:B122). To generate the count, we use the COUNTIF function. The formula in G5, copied through the range G5:G9 is:
The range is the the named rangecategory (B5:B122), and the criteria as is supplied as a reference to F5, which simply picks up the text value in column F. As the formula is copied down, it returns the count of each category listed F5:F9.
To calculate the percentage shown in column H, we need to divide the count per category by the total count. The formula in H5 is:
On the left, COUNTIF is configured as explained above. On the right, we use COUNTA to count total values in named range category (B5:B122) to generate a total count. The formula is evaluated like this:
Note: since we already have a count per category in column G, it would be more efficient to pick the that count in this formula instead of recalculating the same count again in column H. However, COUNTIFS and COUNTA are shown together here as a standalone solution.
Formatting percentages in Excel
In mathematics, a percentage is a number expressed as a fraction of 100. For example, 65% is read as "Sixty-five percent" and is equivalent to 65/100 or 0.65. Accordingly, the values in column H are decimal values, with the Percentage number format applied.
Pivot table option
A pivot table would also be a good way to solve this problem.
When working with data, a common need is to perform summary calculations that show total counts in different ways. For example, total counts by category, color, size, status, etc. The COUNTIF function is a good way to generate these kinds of totals...
In this example, we have a list of 100 issues in Columns B to D. Each issue has a date and priority. We are also using the named range "dates" for C5:C104 and "priorities" for D5:D105. Starting in column F, we have a summary table that shows a total...
In this example, the goal is to work out the "percent of total" for each expense shown in the worksheet. In other words, given that we know the total is $1945, and we know Rent is $700, we want to determine that Rent is 36% of the total. The total...
In this example if a task is marked "Done", then it is considered complete. The goal is to calculate the percent complete for the project by showing the ratio of complete tasks to total tasks, expressed as a percentage. The formula in F6 is: =...
COUNTIF is an Excel function to count cells in a range that meet a single condition. COUNTIF can be used to count cells that contain dates, numbers, and text. The criteria used in COUNTIF supports logical...
The Excel COUNTA function returns the count of cells that contain numbers, text, logical values, error values, and empty text (""). COUNTA does not count empty cells.
Excel Formula Training
Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.