Search code examples
exceltextsumifs

SUMIF Similar Text


I am trying to use SUMIFS to match either of the following criteria:

"Insurance" or "Motor Insurance"

=SUM(SUMIFS(B:B, A:A,{"*Motor Insurance*","*Insurance*"}))

A - Insurance, Motor Insurance, Some Insurance

B - 1, 2, 1

The current result is 6 due to my statement matching any string containing "Insurance". Is there a way write a statement where it'll match it the way I would want it to, i.e. if it contains "Motor Insurance" it won't match "Insurance"?

The result should be 4: 2 for "Insurance" and 2 for "Motor Insurance".

Before anyone asks, I can't do a literal match "Motor Insurance" as these three are within a much larger data set where "Insurance" or "Motor Insurance" with be part of that string.

Here is table

The table above shows that I have three sets of Text and I am trying to get the result of the ones that contain "insurance" and the ones that contain "motor insurance". I understand that one would contain the other but I want the result to be:

"Insurance" is 2 (only matching A2 and A4)

"Motor Insurance" is 2 (only matching A3)


Solution

  • For two separate formulas - one for just "Motor Insurance"

    =SUMIFS(B:B, A:A,"*Motor Insurance*")

    and one for any other Insurance

    =SUMIFS(B:B, A:A,"<>*Motor Insurance*",A:A,"*Insurance*")