is it possible to sum field under condition?

I would like to sum fields within my table but only if they correspond to something...

for exemple, I have product with 2 different type, let say type A and type B. I have a table that correspond to purchased. I would like to be able to sum type A product and type B product.

With this formula I only get the first to be calculated...

sum(if product.type = "A" then purchase.price end, if product2.type ="A" then purchase2.price end)

here the table exemple

purchase   price          purchase2    price2           purchase3      price3

product1    10             product3       5                 product5        20

So I would like to check if the product is type A or B in it s table and sum or not...

thank you!

Hmm.. without drawing out the data model.. Sounds like a view that is grouped on Type.. with a sum on price.

Hi,

If you want both parts to be calculated the formula could be:

`sum(if product.type = "A" then purchase.price end) + sum(if product2.type ="A" then purchase2.price end)`

Kind regards,

Jörg