[Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register]

Author Message
mazarin
General User

Joined: 16 Feb 2009
Posts: 25

 Posted: Wed Apr 22, 2009 7:33 am    Post subject: Alternative formula to SUMIF - Needs more than 1 Criteria Hello Everyone! Let´s consider this table: Project Code | Category | Cost ------------------------------------- AX | 1 | 10 AX | 1 | 10 AX | 1 | 10 AX | 2 | 10 AX | 2 | 10 ZM | 1 | 10 ZM | 1 | 10 ZM | 2 | 10 ZM | 2 | 10 ------------------------------------ I would like to know the total cost for project "AX" on category "1". The expected result is: "30". Since SUMIF allows only 1 criteria, how can I get the result? I´ve tried to obtain this using array formulas and SUMPRODUCT, but I couldn´t make it work. Thanks!Last edited by mazarin on Wed Apr 22, 2009 12:40 pm; edited 1 time in total
JohnV

Joined: 07 Mar 2003
Posts: 8979
Location: Lexinton, Kentucky, USA

 Posted: Wed Apr 22, 2009 7:51 am    Post subject: Take a look at the DSUM function in Help. Note that there is a sample spreadsheet at the top of the help page that is used in the example's syntax.
mazarin
General User

Joined: 16 Feb 2009
Posts: 25

 Posted: Wed Apr 22, 2009 9:40 am    Post subject: Hello JohnV! It seems that DSUM can sucessfully bring the result I want, but doesn´t fit my needs because: 1. I have dozens of criteria combinations (25+ projects and 30 categories) 2. DSUM needs a label / header identical to the database to show the results. This breaks the flexibility of the spreadsheet layout. There is another way to bring the results?
Villeroy
Super User

Joined: 04 Oct 2004
Posts: 10065
Location: Germany

Posted: Wed Apr 22, 2009 10:09 am    Post subject:

 mazarin wrote: Hello JohnV! It seems that DSUM can sucessfully bring the result I want, but doesn´t fit my needs because:

No, you wrote:
 Quote: I would like to know the total cost for project "CIN" on category "1". The expected result is: "50".

Alternatives are:
SUMPRODUCT, data pilots, subtotals, filters with function SUBTOTAL and using a database in the first place instead of spreadsheet lists.
_________________
Rest in peace, oooforum.org
Get help on http://forum.openoffice.org
mazarin
General User

Joined: 16 Feb 2009
Posts: 25

 Posted: Wed Apr 22, 2009 12:25 pm    Post subject: Could you please post a sample of the formula, Villeroy? I´ve got an error on my question, sorry! Let me remake it: I would like to know the total cost for project "AX" on category "1". The expected result is 30.
keme
Moderator

Joined: 30 Aug 2004
Posts: 2732
Location: Egersund, Norway

 Posted: Wed Apr 22, 2009 11:40 pm    Post subject: Assuming your data range is A2:C10, project code is text, and that the other columns are not input as text: =SUMPRODUCT(A2:A10="AX";B2:B10=1;C2:C10)
mazarin
General User

Joined: 16 Feb 2009
Posts: 25

 Posted: Thu Apr 23, 2009 4:57 am    Post subject: It worked! Thanks Keme! So I think that SUMPRODUCT it is the better solution when we need to sum a data range based on two or more criteria. It´s the perfect alternative to SUMIF. Thanks again, and hope this thread helps other people too!
keme
Moderator

Joined: 30 Aug 2004
Posts: 2732
Location: Egersund, Norway

 Posted: Thu Apr 23, 2009 5:34 am    Post subject: You're welcome. SUMPRODUCT() is a surprising solution to this, perhaps. Anyway, since Villeroy enlightened me about its various uses, I've been much less strained when working in Calc.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 All times are GMT - 8 Hours Page 1 of 1

 Jump to: Select a forum OpenOffice.org Forums----------------Setup and TroubleshootingOpenOffice.org WriterOpenOffice.org CalcOpenOffice.org ImpressOpenOffice.org DrawOpenOffice.org MathOpenOffice.org BaseOpenOffice.org Macros and APIOpenOffice.org Code Snippets Community Forums----------------General DiscussionSite Feedback
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum