In the above datasheet, let's find out the total revenue for the "Oil and gas" industry. Since our data set is small we can simply count. If we have 1000s row of the data we can use the COUNTIF function to get the result and the formula will look like this.
=COUNTIF(C3:C7,"Oil and gas") // criteria within formula and a text value must be inside quotation " " marks
=COUNTIF(C3:C7,B12) // criteria as a cell reference
C3:C7 = criteria_range
"Oil and gas" = criteria
💡 "Oil and gas" = criteria are not case sensitive "Oil and Gas", "OIL AND GAS", "Oil And Gas" will produce the same result. As long we have the same text within the criteria, we will get the same result
💡 "1 Oil and Gas", "1 OIL AND GAS", "1 Oil And Gas" will NOT produce the same result.
💡 Access the Google Sheets here used in this exercise. All functions on this page are compatible with Microsoft Excel and the same analysis can be made in Excel
💡 Below explained how to count if a text contains part of the string