Excel/Two logic
Expert: Stuart Resnick - 10/15/2008
Question
QUESTION: I want to know one formula for two inputs & result is one.
please see this example.
1.In my company have three persons - Jhon, Smith & Jakie
2.They are doing sales individually.
3.how can i make a formula calculate their sals daywise.
4.i tried with SUMIF. but with this i can calculate for one logic. it is only for name otherwise for perticular date.
IMAGE: formula
ANSWER: Following the example file you attached, with the data in B3:D20, and results in the table G3:H4, do as follows.
In cell G3, enter the formula:
=SUM(IF($B$3:$B$20=$F3,IF($C$3:$C$20=G$2,$D$3:$D$20,0),0))
as an ARRAY, which means after typing in the formula, instead of hitting Enter, hit Ctrl-shift-enter.
Then copy the formula to G3:H4.
---------- FOLLOW-UP ----------
QUESTION: Thank you very much for the answer.It is working nicely.Now the second thing is if i am going for yearly calculation how can i change the formula? It means now in F3 month instead of date. Please help.see the example image.
Thanks
Eran
IMAGE: formula for year
ANSWER: =SUM(IF(MONTH($B$3:$B$26)=MONTH($F3),IF($C$3:$C$26=G$2,$D$3:$D$26,0),0))
entered as array, as in my original response
---------- FOLLOW-UP ----------
QUESTION: Thank you very much for reply.Just i realize i forget to enter one more detail to my chart.Now it is 3 logic.if it is possible please answer to this also.Now if jhon and Smith selling differant items, in differant days how can we take item wise in particular date.please see the example image.
AnswerIf you understand the concept behind my previous 2 answers, you can adapt it to any situation, adding additional items by imbedding still more IF functions within the array formula.
If you have trouble understanding the complex array formulas I've given previously, there's a simpler method that I'd highly recommend. Until you're comfortable manipulating array formulas on your own, it's best to use SUMIFs instead. Here's how you'd do that.
In cell A3, enter the formula:
=C3&MONTH(B3)&D3
and copy it down col A as far down as your data goes. This col A can be hidden from the user by using white font, or by hiding the entire column. Once the Col A formulas are in place, then it's simple to get whatever data you need using SUMIFs.
Example: if cell H2 is jhon, cell H3 is cd, and cell G4 is Oct-08, then in H4 you'd use the formula:
=SUMIF($A$3:$A$26,H$2&MONTH($G4)&H$3,$E$3:$E$26)
You can use this concept whenever you want to sum based on multiple fields. That is: create a hidden column to concatinate the fields upon which your sum is based, then use that column in your SUMIFs.