How can I compare strings in Google Sheets? Can you provide an example? 2

How can I compare strings in Google Sheets? Can you provide an example?

To compare strings in Google Sheets, you can use the “IF” function along with the “EXACT” function. The “EXACT” function compares two strings and returns “TRUE” if they are exactly the same, and “FALSE” if they are not. This can be used in combination with the “IF” function to create a formula that compares two strings and returns a desired result based on the comparison. For example, if cell A1 contains the string “apple” and cell B1 contains the string “banana”, the formula “=IF(EXACT(A1,B1), “Fruits match”, “Fruits do not match”)” would return “Fruits do not match” since the two strings are not identical. This method can be used for various purposes, such as checking for duplicates or finding matching values in a data set.

Compare Strings in Google Sheets (With Example)


You can use the following methods to compare strings in cells A2 and B2 in Google Sheets:

Method 1: Compare Strings (Case-Sensitive)

=EXACT(A2, B2)

This formula returns TRUE if the two strings have identical characters in identical cases. Otherwise it returns FALSE.

Method 2: Compare Strings (Case-Insensitive)

=EXACT(UPPER(A2),UPPER(B2))

This formula returns TRUE if the two strings have identical characters, regardless of case. Otherwise it returns FALSE.

The following examples show how to use each method in practice with the following columns of strings in Google Sheets:

Example 1: Compare Strings in Google Sheets (Case-Sensitive)

We can type the following formula into cell C2 to check if the strings in cell A2 and B2 are equal, including their case:

=EXACT(A2, B2)

We can then drag and fill this formula down to each remaining cell in column C:

compare strings in Google Sheets

The formula in column C only returns  TRUE if the characters in each string and the cases of the characters are identical.

Otherwise, the formula in column C returns FALSE.

For example:

  • Panda and panda have the same characters but they’re not in the same case, so the formula returns FALSE.
  • lion and lion have the same characters and they’re in the same case, so the formula returns TRUE.

And so on.

Example 2: Compare Strings in Google Sheets (Case-Insensitive)

We can type the following formula into cell C2 to check if the strings in cell A2 and B2 are equal, regardless of case:

=EXACT(UPPER(A2),UPPER(B2))

We can then drag and fill this formula down to each remaining cell in column C:

The formula in column C returns TRUE if the characters in each string are equal, regardless of case.

Otherwise, the formula in column C returns FALSE.

Note that this formula uses the UPPER function to first convert each string to uppercase before comparing the characters.

This is equivalent to performing a case-insensitive comparison since it guarantees that each string is converted to all uppercase characters before performing the comparison.

The following tutorials provide additional information on how to work with dates in Google Sheets:

Cite this article

stats writer (2024). How can I compare strings in Google Sheets? Can you provide an example?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-i-compare-strings-in-google-sheets-can-you-provide-an-example/

stats writer. "How can I compare strings in Google Sheets? Can you provide an example?." PSYCHOLOGICAL SCALES, 23 Jun. 2024, https://scales.arabpsychology.com/stats/how-can-i-compare-strings-in-google-sheets-can-you-provide-an-example/.

stats writer. "How can I compare strings in Google Sheets? Can you provide an example?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-i-compare-strings-in-google-sheets-can-you-provide-an-example/.

stats writer (2024) 'How can I compare strings in Google Sheets? Can you provide an example?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-i-compare-strings-in-google-sheets-can-you-provide-an-example/.

[1] stats writer, "How can I compare strings in Google Sheets? Can you provide an example?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.

stats writer. How can I compare strings in Google Sheets? Can you provide an example?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.

Download Post (.PDF)
Slide Up
x
PDF
Scroll to Top