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

Build Hyperlink With VLOOKUP in Excel

You might have come across a task in which you were assigned to build hyperlinks, which seems very easy, and if you are new to excel or don't have enough experience with it, then you might wonder about doing this ...

Calculate Total Cost with Excel VLOOKUP Function

In today's article we will show you how to calculate the total cost for a given weight using the Excel VLOOKUP function. This function will help us to find the appropriate unit price for that weight and then we can ...

Basic Price Discount Calculation with Excel VLOOKUP Function

We often encounter product discounts in our shopping. Depending on the level of spending, the mall will offer different percentages of discounts. Usually, the more you spend, the bigger the discount, while the less you spend, the smaller the discount. ...

Calculate Grades With VLookup in Excel

Why Should You Calculate Grades With VLookup Excel? If you're looking for a simple way to find out a student's grades, VLOOKUP Excel can do the trick. This function uses a lookup table to find the values and sort them ...

Convert State Names To Abbreviations
abbr state names1

Assume that you got a task to convert the full state's name into the abbreviations in MS Excel, and for doing this task, you might choose to do it manually, which is an acceptable way only if you don't have ...

Find and Replace Multiple Values
find replace multiple values5

This post will guide you how to find and replace multiple values at once with VBA macro or using formula  in Excel. How do I make multiple find and replace in Excel. Suppose that you have a few cells containing ...

Excel XLOOKUP Function

Excel XLOOKUP Function was added into Excel as a beta feature in August 2019 and is now accessible exclusively in Microsoft 365. (as of July 2021). However, if you fall into this category and often deal with big sets of ...

VLOOKUP Formula | Faster Trick with 2 VLOOKUPS

This post will guide you how to use 2 VLOOKUPS function to looking up data entries from a given range of cells in Microsoft Excel. VLOOKUP with 2 lookups can be faster than a single VLOOKUP in certain scenarios. The ...

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 ...

Sidebar