CPPMOOC - COUNTIF Function - Week 1 Supplemental

1
Counting the number of similar entries using the COUNTIF function COUNTIF is a built-in spreadsheet function that calculates the number of times a specific value appears in a range of cells. The syntax of the COUNTIF function is the following: COUNTIF(range, criteria) If the criteria is text (also called a character string) the text needs to be inside double quotes. For example, below is a spreadsheet that contains information about passengers on an airplane. Column A lists the passengers’ names, column B lists the dinner each passenger ordered, and column C lists the number of bags checked in by each passenger. If we want to know how many passengers ordered fish for dinner, we use the command: =COUNTIF(B2:B10, "fish") This command determines the number of times the text "fish" appears in cells B2 through B10. The resulting answer is 6. Notice that double quotes are required since the criteria was a character string. If we want to know how many passengers did not check in a bag, we use the command: =COUNTIF(C2:C10, 0) This command determines the number of times the number 0 appears in cells C2 through C10. The resulting answer is 4. Notice that no double quotes are required since the criteria was a number.

description

CPPMOOC - COUNTIF Function - Week 1 Supplemental

Transcript of CPPMOOC - COUNTIF Function - Week 1 Supplemental

Page 1: CPPMOOC - COUNTIF Function - Week 1 Supplemental

Counting the number of similar entries using the COUNTIF function COUNTIF is a built-in spreadsheet function that calculates the number of times a specific value appears in a range of cells. The syntax of the COUNTIF function is the following: COUNTIF(range, criteria) If the criteria is text (also called a character string) the text needs to be inside double quotes. For example, below is a spreadsheet that contains information about passengers on an airplane. Column A lists the passengers’ names, column B lists the dinner each passenger ordered, and column C lists the number of bags checked in by each passenger.

If we want to know how many passengers ordered fish for dinner, we use the command: =COUNTIF(B2:B10, "fish") This command determines the number of times the text "fish" appears in cells B2 through B10. The resulting answer is 6. Notice that double quotes are required since the criteria was a character string. If we want to know how many passengers did not check in a bag, we use the command: =COUNTIF(C2:C10, 0) This command determines the number of times the number 0 appears in cells C2 through C10. The resulting answer is 4. Notice that no double quotes are required since the criteria was a number.