selective SUMPRODUCT

I have a database made of:
column A - currency
column B - amount
column C - duration

criteria =currency

I need to calculate average duration for each currency.

I'm using:

DSUM(database;"amount";criteria) to get the total amount denominated in EUR

If I would have only one currency I can easily get the average duration by sumproduct(b:b;c:c) and then divide the result of sumproduct by  the result of dsum.
The issue is that I have many currencies, therefore I need a sumproduct which multiplies only values which have the same criteria as the dsum formula.
Is there a way to do it?


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I think what you want is:

=average(SUMIF(range, EUR))

This fmla must be an array formula, so press Ctrl-Shift-Enter after typing it
Actually, this works better:


It still has to be an array formula.
barry houdiniCommented:
If you are using DSUM for the total Euros then why not DAVERAGE for the average?


regards, barry
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

yuppyduAuthor Commented:
Probably I've not explained myself correctly:

What I need is to sum the product of column b and column c only for those rows which match the criteria
barry houdiniCommented:
OK, If you have a single currency then you can use SUMPRODUCT like this


or for multiple currencies


adjust ranges as required

regards, barry

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
yuppyduAuthor Commented:
here an example

currency     nominal    dur
eur              200000     5
eur            1000000     6
sek            5000000    10



Dsum(database;"nominal";"eur") gives me 1200000

I need a sumproduct of: 200000*5;1000000*6 i.e. only for pairs which have eur as currency value
barry houdiniCommented:
Sorry some of the commas in that second formula should be semi-colons like this



barry houdiniCommented:
As per my previous answer but one.....



yuppyduAuthor Commented:
Thanks Barry, as usual your formulas are precise, complete and easy to implement.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.