Case Sensitive Lookup with SUMPRODUCT and EXACT

Today, we will show you how to use SUMPRODUCT and EXACT to perform a case sensitive exact match. In this article, we provide a simple example to calculate bonus for employees whose names are case-sensitive. If you meet similar scenarios in your daily work, you can directly use this formula to deal with your problem.

EXAMPLE

In this example, first name “Cathy” and “CATHY” are duplicate but they have different last name. To calculate bonus for “CATHY” correctly, we need to ignore “Cathy” from the list and find out “CATHY” properly, then retrieve bonus “$1,500.00” from cell C5 properly. To solve this problem, we can create a formula that can perform case-sensitive lookup and retrieves data from a particular position based on the lookup value.

Before creating the formula, to make cell reference and range reference used in the formula are easy to understand, we named range (A2:A6) to “Name”, (C2:C6) to “Bonus”. In this example, we will apply SUMPRODUCT function together with EXACT to perform an exact match.

ANALYSIS

The formula can perform below operations:

1. It can scan values from “First Name” column and find out lookup value “CATHY” properly.

2. As we have two “Cathy”, we need to ignore the first “Cathy”. Because for the first one, except the first letter, other letters are entered in lowercase. But for our input value “CATHY”, all five letters are entered in UPPERCASE. They are different if case sensitive.

3. After confirming the position of “CATHY”, it can retrieve data from “Bonus” column in the same row of “CATHY”.

4. It returns proper bonus get in step#3 after performing the formula.

Actually, there are some powerful functions and function combinations that can perform lookup effectively and powerfully, for example VLOOKUP function or INDEX/MATCH function combination. However, no matter VLOOKUP function or INDEX/MATCH functions, they are not case-sensitive functions. They will return the first match result ignoring case. So, we need the help from other functions that are case-sensitive and can perform case-sensitive comparison properly. In Excel, EXACT is frequently used for case-sensitive comparison, so, in this example, we will create a formula with EXACT function. At the core, this is a SUMPRODUCT formula, EXACT is applied inside SUMPRODUCT function to perform case-sensitive comparison.

The formula: SUMPRODUCT(–EXACT(E2,Name),Bonus)

 

FORMULA

Input formula =SUMPRODUCT(–EXACT(E2,Name),Bonus) into F2. As this is an array formula, so we must press Control+Shift+ENTER to return result. Verify that “$1,500.00” is displayed properly.

FUNCTION INTRODUCTION

a. SUMPRODUCT function can be seen as SUM+PRODUCT. It returns the sum of products of corresponding ranges or arrays.

Syntax:

=SUMPRODUCT(array1,array2,array3, ...)

b. EXACT function is case-sensitive, it can detect whether two strings are exactly the same. If yes, it returns TRUE, else it returns FALSE.

Syntax:

=EXACT(text1, text2)

 EXPLANATION

=SUMPRODUCT(--EXACT(E2,Name),Bonus)

a. EXACT(E2,Name) performs a case-sensitive comparison between value in E2 (“CATHY”) and values in “Name”({“Cathy”;”Ben”;”Kelly”;”CATHY”;”Serena”}). It returns “TRUE” if the two strings are exactly the same. So, after comparison, we get below an array of “TRUE” and “FALSE”:

{FALSE;FALSE;FALSE;TRUE;FALSE}

Select EXACT(E2,Name) in the formula bar and press F9, you can see the result returned by EXACT function:

b. We add double negative to coerce “TRUE” into number “1” and FALSE into number “0”. Then we get below array consists of numbers “1” and “0”:

{0;0;0;1;0}

Select –{FALSE;FALSE;FALSE;TRUE;FALSE} and press F9:

c. {0;0;0;1;0} is delivered to SUMPRODUCT function as one array. In this array, “1” represents “CATHY”, its position in the array reflects the position of “CATHY” in range “Name”.

 d. Expand values in “Bonus”:

{1000;2000;2000;1500;1600}

 Select “Bonus” and press F9:

 SUMPRODUCT multiplies the items in each array and get result {0;0;0;1500;0}; Then returns sum of product: 1500.

 NOTICE

 1. SUMPRODUCT only works when items are numeric values in each array. So, in this case, if values in named range “Bonus” are texts, SUMPRODUCT doesn’t work. If you want to retrieve text, you can apply VLOOKUP or INDEX/MATCH with EXACT function.

 2. This formula doesn’t work properly if there are multiple matches. It will return the sum of all matches. For example, two “CATHY”.

    

Related Functions


  • Excel INDEX function
    The Excel INDEX function returns a value from a table based on the index (row number and column number)The INDEX function is a build-in function in Microsoft Excel and it is categorized as a Lookup and Reference Function.The syntax of the INDEX function is as below:= INDEX (array, row_num,[column_num])…
  • Excel MATCH  function
    The Excel MATCH function search a value in an array and returns the position of that item.The MATCH function is a build-in function in Microsoft Excel and it is categorized as a Lookup and Reference Function.The syntax of the MATCH function is as below:= MATCH  (lookup_value, lookup_array, [match_type])….
  • Excel EXACT function
    The Excel EXACT function compares if two text strings are the same and returns TRUE if they are the same, Or, it will return FALSE.The syntax of the EXACT function is as below:= EXACT (text1,text2)…
  • Excel VLOOKUP function
    The Excel VLOOKUP function lookup a value in the first column of the table and return the value in the same row based on index_num position.The syntax of the VLOOKUP function is as below:= VLOOKUP (lookup_value, table_array, column_index_num,[range_lookup])….
  • Excel SUMPRODUCT function
    The Excel SUMPRODUCT function multiplies corresponding components in the given one or more arrays or ranges, and returns the sum of those products.The syntax of the SUMPRODUCT function is as below:= SUMPRODUCT (array1,[array2],…)…

 

Related Posts

VBA Macro For VLOOKUP From Another Sheet
vba macro for vlookup from another sheet1

In the previous post, you should know that how to fix or remove the #N/A error when using VLOOKUP formula to lookup value from another sheet. And this post will show you how to use VBA code to vlookup data ...

VLOOKUP From Another Sheet Not Working
vlookup from another sheet not working3

In the previous post, you should know that how to fix or remove the #N/A error when using VLOOKUP formula to lookup value from another sheet. And this post will show you reasons why your VLOOKUP formula is not working ...

Fix #N/A Error For VLOOKUP From Another Sheet
vlookup from anther sheet not working1

This post will show you how to fix the #N/A error why it occurs when you extract values from another sheet using VLOOKUP function in Excel 2016,2013,2010 or other Excel versions. How can you correct a #N/A error in VLOOKUP ...

Get Employee Information by VLOOKUP

VLOOKUP is one of the key functions among all lookup & reference functions in Excel. Today, in this article, we will show you the way to apply VLOOKUP to retrieve employee information. I hope this article will help you in ...

VLOOKUP with Two Lookup Tables

VLOOKUP is one of the key functions among all lookup & reference functions in Excel. Today we will show you the application of VLOOKUP function when there are two lookup tables. EXAMPLE Table1 and table2 record the rates of Y2020 ...

VLOOKUP with Multiple Lookup Values

VLOOKUP is one of the key functions among all lookup & reference functions in Excel. It can scan and retrieve data from a static or dynamic table based on your lookup value. It can perform approximate match or exact match ...

VLOOKUP Data by Date

VLOOKUP is one of the key functions among all lookup & reference functions in Excel. It can scan and retrieve data from a static or dynamic table based on your lookup value. It can perform approximate match or exact match ...

VLOOKUP – Retrieve Data from Another Workbook
VLOOKUP - Retrieve Data from Another Workbook 1

VLOOKUP is one of the key functions among all lookup & reference functions in Excel. It can scan and retrieve data from a static or dynamic table based on your lookup value. It can perform approximate match or exact match ...

VLOOKUP – Retrieve Data from Another Worksheet
VLOOKUP - Retrieve Data from Another Worksheet 3

VLOOKUP is one of the key functions among all lookup & reference functions in Excel. It can scan and retrieve data from a static or dynamic table based on your lookup value. It can perform approximate match or exact match ...

Basic Grade Calculation by VLOOKUP Function – Approximate Match

In Excel, except combination INDEX+MATCH, we can also apply other functions to search data, for example VLOOKUP function. Like MATCH function, VLOOKUP function is one of Excel lookup & reference functions that can perform approximate match or exact match by ...

Sidebar