You are here:

- Home
- Computing/Technology
- Business Software
- Excel
- sum product formula

Advertisement

QUESTION: I have one spreadsheet that has the following columns, year end date (2012, 2013, 2011, etc..), account type, account name, assets. One the second spreadsheet I created 2 drop down boxes one has in it the following list: last year, last 5 years, last 10 years, the other has a list of all the account types. I am trying to create a sumproduct formula that will calculate the assets based off of what I select in both drop down boxes."

ANSWER: Daveena

Assume

Sheet1

A2:A1000 end date year as you show ex: 2012

B2:B1000 account type

C2:C1000 account name

D2:D1000 assets (assume this is a number to be summed)

Sheet2

A1 will hold either "Last year", "Last 5 years", "Last 10 Years"

B1 will hold an accout type

c1: =IF(A1="",0,IF(A1="last year",SUMPRODUCT(--(Sheet1!$A$2:$A$1000=YEAR(TODAY())-1),--(Sheet1!$B$2:$B$1000=B1),Sheet1!$D$2:$D$1000),SUMPRODUCT(--(Sheet1!$A$2:$A$1000>YEAR(TODAY())-IF(A1="last 5 years",5,10)),--(Sheet1!$B$2:$B$1000=B1),Sheet1!$D$2:$D$1000)))

I have to use two sumproducts because of the way you stated your situation.

I interpret last year as just the assets for the selected accounts in 2012

for last 5 years I would sum 2009, 2010, 2011, 2012, 2013

last 10 years would be 2004 - 2013

So last year excludes the current year. But I have included the current year for last 5 and last 10. This may be an incorrect interpretation and the formula could be modified if it is, but this is what I understood your description to say.

Formula was tested and worked as I describe.

--

Regards,

Tom Ogilvy

[an error occurred while processing this directive]---------- FOLLOW-UP ----------

QUESTION: I was trying to use this formula where column D is year end, Column E is the account type, Column I is the status, and column K is the assets.

C2 is numbers 1,2,3,4,5,6.....10 meaning last 1 year, last 2 years, etc

and column c3 is a dropdown box. However my formula does not work

=SUM(IF(Flows!$D:$D>(MAX(Flows!$D:$D)-$C$2),SUMPRODUCT(--(Flows!$E:$E='Product Past Years'!$C$3),Flows!$I:$I="New Account",Flows!$K:$K)))

ANSWER: Daveena,

You have to have all your conditions within the sumproduct

This worked for me as I understand your requirement:

=SUMPRODUCT(--(flows!$D:$D>(MAX(flows!$D:$D)-$C$2)),--(flows!$E:$E='Product Past Years'!$C$3),--(flows!$I:$I="New Account"),flows!$K:$K)

Again, you will have to determing if the results of flows!$D:$D>(MAX(flows!$D:$D)-$C$2) give you the correct years to include in the sum. (i.e. the value in C2 produces a sum against the correct years).

--

Regards,

Tom Ogilvy

---------- FOLLOW-UP ----------

QUESTION: Hi Tom,

It worked! Thank you so much!

I am calculating the value in C2 based on end of year. So wouldn't it be correct? because if 2013 - 1 would equal anything in year ending 2012.

and when 2014 comes if C2 equals 1 then it will calculate anything in year ending 2013. Am I thinking about this correctly?

Also, if I wanted to count the number of accounts that fall in this category, could I use the same formula by just changing the sumproduct to countif?

Daveena,

That sounds reasonable. You might want to do a filter on your data just to compare the sum.

as far as the count, you would just remove the Asset column

=SUMPRODUCT(--(flows!$D:$D>(MAX(flows!$D:$D)-$C$2)),--(flows!$E:$E='Product Past Years'!$C$3),--(flows!$I:$I="New Account"),flows!$K:$K)

becomes

=SUMPRODUCT(--(flows!$D:$D>(MAX(flows!$D:$D)-$C$2)),--(flows!$E:$E='Product Past Years'!$C$3),--(flows!$I:$I="New Account"))

Countif will only do one condition. You could use the new COUNTIFS which does multiple conditions, but if the sumproduct is working then why change. COUNTIF and COUNTIFS would require some changes to the conditions since it doesn't support the same structure as sumproduct.

--

Regards,

Tom Ogilvy

This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

Answers by Expert:

Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]

Extensive experience. **Education/Credentials**

Master of Science (MS) degree Operations Research (ORSA)**Awards and Honors**

Microsoft MVP in Excel.