I have data in a sheet similar to the image. There are rows with duplicate Product ID information and I want to calculate the total cost of a unique Product that matches multiple criteria.

In this example, I want to calculate the cost where Type = Large and Version = A. The total in this example will be $30.

enter image description here

1 Answer 1


Use QUERY and UNIQUE like this:

=QUERY(UNIQUE(A:D), "Select SUM(Col4)
   where Col2='Large' and Col3='A' 
   label SUM(Col4) 'Total'") 

You can remove the label by replacing 'Total' with '' in the formula (no space between ticks).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.