简体   繁体   中英

Excel Sum Range Match Lookup

I have the following table in excel:

__|______A_______|_________B___________|____C____|                        
1 |Client        | Description         | Amount  |
2 |Client One    | Water Services      | 50      |
3 |Client One    | Installation Fees   | 120     |
4 |Client One    | Telephone Services  | 130     |
5 |Client Two    | Food Services       | 20      |
6 |Client Two    | Pump Installation   | 40      |
7 |Client Two    | Door Installation   | 100     |
8 |Client Three  | Telephone Services  | 98      |
9 |Client Three  | Gas Services        | 34      |
10|Client Three  | Installation Fees   | 46      |

I need a formula to calculate the total amount of services for each client and total amount of installation for each client in a second worksheet. For example it should check if the description contains the text "services" in the column B then return the total amount for the client as follows:

__|____A________|______B_________|______C_______|
1 |Client       | Description   | Total Amount |
2 |Client One   | Services      | 180          |
3 |Client One   | Installation  | 120          |
4 |Client Two   | Services      | 20           |
5 |Client Two   | Installation  | 140          |
6 |Client Three | Services      | 132          |
7 |Client Three | Installation  | 46           |

I have tried the following formula, but I was able to only return the first value for the client and the description (Column B) in sheet 1 has to contain the exact text, that is either "Services" or "Installation":

=INDEX(Sheet1!C2:C10,MATCH(A2&B2,Sheet1!A2:A10&Sheet1!B2:B10,0))
  1. I need to be able to get the total value instead of the first value.
  2. I also needs to search if the the description contain the "Services" or "Installation" then return the amount.

Here is one way to do it:

=SUM(($A$2:$A$10=A13)*(IFERROR(FIND(B13,$B$2:$B$10),0)>0)*$C$2:$C$10)

This is an array formula so to enter the formula press Ctrl + Shift + Enter (rather than just Enter )

在此处输入图片说明

I support the solution by CallumDA, as I'm personally a fan of array formulas. However, since the nature of OP's questions suggests somewhat limited Excel-experience, I think Array formulas might be aiming a bit high.

A, in my opinion, simpler alternative is to use SUMIFS -formula, eg

=SUMIFS($C$2:$C$10;$A$2:$A$10;"Client One";$B$2:$B$10;"*Service*")

Just replace the "Client One" with the range of the other table where you have the clients listed, and I believe you should be good to go. Also, note that the asterix on either side of Service function as wildcards so that you get both "Water Service", "Service Truck" and other combinations...

You could do something with SUMIF . You could do something like this to get all of your Client One entries

=SUMIF(A2:A10,"Client One",C2:C10)

And to get all of your Client One and Services you could do something like this with ISNUMBER(SEARCH) and SUMIFS

First add an extra column for "Is a Service" with this formula

=ISNUMBER(SEARCH("Service",B1))
=ISNUMBER(SEARCH("Service",B2))
...

This will return true/false and then do SUMIFS like this

=SUMIFS(A2:A10,C2:C10,"Client One",D2:D10,"TRUE")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM