Excel/Two logic

Advertisement


Question

Formula for three logi
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.

Answer
If 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.
About Excel
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

Stuart Resnick

Expertise

I can answer any question relating to MS Excel formulas, or to programming with vba (Visual Basic for Applications) in the Excel environment

Experience

As a consultant, I've designed Excel tools since the 90s, working for the Federal Reserve Bank, AT&T, and (currently) Gap Inc.

©2009 About.com, a part of The New York Times Company. All rights reserved.