views:

388

answers:

1

I have a row with a cost, item type and a "tags" columns. I want to be able to find the total cost of all rows containing a certain "tag". I tried using VLOOKUP but I keep on getting a $0.00 return.

Example Row Setup:
    PART NUMBER - COST - TAGS - MANU ID - WEIGHT
    0001025-SVR - 25.99 - JP, CABLES, PVC - 17.4
    0A06422-SVR - 14.27 - SOLENOID, COPPER - 4.6
    ZZZ4244-XUM - 25047.22 - PLAT, JP, HEADER, RACTIVE - 2488.25

Looking for JP Tag. Should return: 25073.21, which is the total of the first and last row. VLOOKUP("JP",A2:D4,2) is what I have tried, along with the filter function but still cannot seem to get it to work correctly.

+1  A: 

Edit: My first solution will work in Excel, but not Google Docs.

Try this instead (tested):

=SUM(IFERROR(FILTER( B7:B200 ; SEARCH( "JP" ; E7:E200 ));0))

You'll want the SumIf function.

Assuming your costs are in column B, and your tags in column C this should work:

=SumIf(C2:C4, "*" & "JP" & "*", B2:B4)

The * are wildcards that will match anything to the left and right of "JP".

Adam Bernier
txmail
@txmail: see Google Docs-specific solution above. My first solution will work in Excel only.
Adam Bernier
Makrked the question as answered but didnt get a chance to try it until just now and it still just returns 0? =SUM(IFERROR(FILTER(JAN!E7:E200,SEARCH("RACTIVE")),0))Could it be that this is not working because this is on another sheet? I also tried to take out the position and used commas instead of semi-colons (I did try it the way it was stated too).
txmail
Wait.. you are right. I had the array for the filter specified incorrectly! Genius! Here is what I ended up using: =SUM(IFERROR(FILTER(JAN!B7:B200,SEARCH( "RACTIVE", JAN!E7:E200)),0))
txmail
@txmail: Yep, the order of formula arguments is different in the two programs. IMO the Google Docs order makes more sense, and the Google Docs formula is more explicit about what it's doing. Cheers!
Adam Bernier