Question

In Excel I need to Sum Values, but only if ANY of a full column of text values appears in a specific column. In other words: "Sum the Values [Column X] where Country=Y, but only where ID= [anything from A2:A2000, formatted as text]. If the ID isn't one of those values in the range, I don't want the Row value for Country=Y to be Summed.

I can't do this line-by-line, so I'm looking for the syntax of a range vs. another range., since the ID "keys" are in a separate column than the countries to be Summed by.

Column A = individual Countries, in a separate table we have a very long list of "valid" IDs. From the main data table, I want to Sumif Widgets column by Country, but only where ID = one of the IDs in the "valid' ID table.

Was it helpful?

Solution

You can use SUMIFS and SUMPRODUCT.

Let's say Sheet1 column A has the countries, Sheet1 column B has the IDs, Sheet1 column C has the values, Sheet2 column A has the IDs to match and all tables have headers in row 1. This formula is being put on Sheet1.

=SUMPRODUCT(SUMIFS($C$2:$C$100,$A$2:$A$100,"CountryName",$B$2:$B$100,Sheet2!$A$2:$A$100))

SUMIFS gives the sum of range C2:C100, for which the range A2:A100 corresponds to the text "Countryname", and for which the IDs in range B2:B100 correspond to the IDs on the other sheets. The values returned are in an array, and as such, you uses SUMPRODUCT to sum them up.

Change the range references accordingly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top