• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

SUMPRODUCT, IF, SUMIF or... with an array and some subraction

erinm1965

New Member
Hi. I've been using SUMPRODUCT with arrays throughout this project, but now I need to end the array checking with subtraction. I am getting a #VALUE value (which is usually formatting, but the formatting checks out).

=SUMPRODUCT(--('All Transactions'!AE2:AE5348=' Budget Financial Tracking'!H9),--('All Transactions'!AD2:AD5348=' Budget Financial Tracking'!K4),--('All Transactions'!F2:F5348=' Budget Financial Tracking'!K6),'All Transactions'!Q2-'All Transactions'!S2)

What I am doing here is checking to see if the data in three arrays matches its identifier (K4, K6 and H9). Where there is a match (and there will always be a match), then I want the arithmetic (Q2-S2) to be performed.


I think I am close...


Thanks,
 
Hi, erinm1965!


First of all welcome to Chandoo's website Excel forums. Thank you for your joining us and glad to have you here.


As a starting point I'd recommend you to read the green sticky topics at this forums main page. There you'll find general guidelines about how this site and community operates (introducing yourself, posting files, netiquette rules, and so on).


Among them you're prompted to perform searches within this site before posting, because maybe your question had been answered yet.


Feel free to play with different keywords so as to be led thru a wide variety of articles and posts, and if you don't find anything that solves your problem or guides you towards a solution, you'll always be welcome back here. Tell us what you've done, consider uploading a sample file as recommended, and somebody surely will read your post and help you.


And about questions in general...


If you haven't performed yet the search herein, try going to the topmost right zone of this page (Custom Search), type the keywords used in Tags field when creating the topic or other proper words and press Search button. You'd retrieve many links from this website, like the following one(s) -if any posted below-, maybe you find useful information and even the solution. If not please advise so as people who read it could get back to you as soon as possible.


And about this question in particular...


The last term of your formula shouldn't it be like this?

'All Transactions'!Q2:Q5348-'All Transactions'!S2:S5348


Regards!
 
Dear SirJB7,


Thank you for your informative post. I have made an introduction. I did search through the forum for an answer to my issue before posting but did not see anything. If I missed it and you want to point me to a previous post that is pertinent, please do.


In theory your solution should work however the #VALUE error is returned.


My alternative is to punt and break the statements out; which works fine.
 
Hello Erin,

Are you wanting to multiply the result of Q2-S2 with the count of the rows where the conditions were matched? If so, put the Q2-S2 outside of the SUMPRODUCT.


Example:

=SUMPRODUCT(....) * (Q2-S2)


In this case, if 10 rows match your conditions, then you will get 10*(Q2-S2).


On the other hand, if you want to subtract column Q from column S, use the suggestion that SirJB7 provided. Feel free to post your sample workbook if neither of these solutions work for you.


Cheers,

Sajan.
 
Hi, erinm1965!


Thanks for the acknowledge, and actually I read this topic before checking the Introduce Yourself one.


Regarding the #VALUE error you'd try 2 things but I think they both will do the job. If they did.

1) Change your last term in the formula to:

--('All Transactions'!Q2:Q5348-'All Transactions'!S2:S5348) as all the other previous

2) Change your whole formula to:

=SUMPRODUCT(('All Transactions'!AE2:AE5348=' Budget Financial Tracking'!H9)*('All Transactions'!AD2:AD5348=' Budget Financial Tracking'!K4)*('All Transactions'!F2:F5348=' Budget Financial Tracking'!K6)*('All Transactions'!Q2-'All Transactions'!S2))


If none works, keep 2nd format and try this:

3) Try to force numerical values:

=SUMPRODUCT((1*('All Transactions'!AE2:AE5348=' Budget Financial Tracking'!H9))*(1*('All Transactions'!AD2:AD5348=' Budget Financial Tracking'!K4))*(1*('All Transactions'!F2:F5348=' Budget Financial Tracking'!K6)*('All Transactions'!Q2-'All Transactions'!S2)))


If still with issues, either error values or wrong values, consider performing a check on Q and S columns with a formula in column R like:

=SI(Y(ESNUMERO(Q2);ESNUMERO(S2));"";"X") -----> in english: =IF(AND(ISNUMBER(Q2),ISNUMBER(S2)),"","X")

In any cell place this formula:

=CONTAR.SI(R:R;"X") -----> in english: =COUNTIF(R:R,"X")

and check if it's 0 or not.


If it's zero, I ran out of script; if not, filter column R for "X" and check involved cells in Q & S column.


Otherwise consider uploading a sample file (including manual examples of desired output if applicable), it'd be very useful for those who read this and might be able to help you. Thank you. Give a look at the green sticky posts at this forums main page for uploading guidelines.


Regards!
 
Back
Top