MS Office Forum / Excel / New Users / March 2005
Shortening SUMPRODUCT formulas
|
|
Thread rating:  |
Dluxe - 01 Mar 2005 13:32 GMT Hi all.
This is a re-post, in a sense, of a question I posted last week to this forum.
I work at a college and use SUMPRODUCT formulas to total up all kinds of stuff. For example, to calculate the number of people majoring in a particular area (in this case, Social Sciences and Arts), I use the following: =SUMPRODUCT(((Major="African/African Am Studies")+(Major="Ancient History")+(Major="Art")+(Major="Art History")+(Major="Asian Studies")+(Major="Chinese")+(Major="Classics")+(Major="Classical Studies")+(Major="Communication Theory")+(Major="Comparative Literature")+(Major="Drama")+(Major="Education")+(Major="English")+(Major="F ilm Studies")+(Major="French")+(Major="Government")+(Major="Health Policy")+(Major="History")+(Major="Humanities")+(Major="Human Development & Education")+(...etc..)+(Major="Visual Studies")+(Major="War and Peace Studies"))*((Decision="BA")+(Decision="BB")+(Decision="BC"))*(Round="1"))
Some of these formulas are getting too long for excel. I posted asking if a lookup function was the right way to fix it... A reply suggested the following: =SUMPRODUCT(--(Major={"African/African Am Studies","Ancient History","Art","Art History",etc...}))
Which works for counting the majors by themselves, but I can't seem to the other conditions in (like DECISION and ROUND) using the same format. I tried something like this: =SUMPRODUCT(((--(Major={"Economics","Finance","Inter'l Economic Policy","Monetary & Financial Policy","Public Economics"}))*(--(Decision={"BA","BC"}))*(Round="1")))
But as soon as I combine two of the --(Major={ things, I get an #N/A error.
Any thoughts/help appreciated.
Best, Dluxe
Don Guillett - 01 Mar 2005 13:52 GMT Seem like it may be easier to exclude <> vs = Anyway try this =(major={"a","b","c","etc"})
 Signature Don Guillett SalesAid Software donaldb@281.com
> Hi all. > [quoted text clipped - 9 lines] > Studies")+(Major="Chinese")+(Major="Classics")+(Major="Classical > Studies")+(Major="Communication Theory")+(Major="Comparative Literature")+(Major="Drama")+(Major="Education")+(Major="English")+(Major="F
> ilm Studies")+(Major="French")+(Major="Government")+(Major="Health > Policy")+(Major="History")+(Major="Humanities")+(Major="Human Development & [quoted text clipped - 19 lines] > > Best, Dluxe Dluxe - 01 Mar 2005 16:55 GMT Well, the trick is that I have to look at majors for different subsets of people (I'm feeding this spreadsheet with a ODBC pull from a database).
So, I need to be able to say For people with THESE majors, from this ROUND, who we've coded THIS way.
> Seem like it may be easier to exclude <> vs = > Anyway try this [quoted text clipped - 13 lines] > > Studies")+(Major="Chinese")+(Major="Classics")+(Major="Classical > > Studies")+(Major="Communication Theory")+(Major="Comparative Literature")+(Major="Drama")+(Major="Education")+(Major="English")+(Major="F
> > ilm Studies")+(Major="French")+(Major="Government")+(Major="Health > > Policy")+(Major="History")+(Major="Humanities")+(Major="Human Development > & > > Education")+(...etc..)+(Major="Visual Studies")+(Major="War and Peace Studies"))*((Decision="BA")+(Decision="BB")+(Decision="BC"))*(Round="1"))
> > Some of these formulas are getting too long for excel. I posted asking if > a [quoted text clipped - 16 lines] > > > > Best, Dluxe Bob Phillips - 01 Mar 2005 14:01 GMT The problem is that your comparison arrays are different sizes, screwing up the formula.
The best I could do was this, but it defeats part of your purpose
=SUMPRODUCT((Major={"Economics","Finance","Inter'l Economic Policy","Monetary & Financial Policy","Public Economics","Economics","Finance","Inter'l Economic Policy","Monetary & Financial Policy","Public Economics"})*(Decision={"BA","BA","BA","BA","BA","BC","BC","BC","BC","BC"})* (Round={"1","1","1","1","1","1","1","1","1","1"}))
 Signature HTH
RP (remove nothere from the email address if mailing direct)
> Hi all. > [quoted text clipped - 9 lines] > Studies")+(Major="Chinese")+(Major="Classics")+(Major="Classical > Studies")+(Major="Communication Theory")+(Major="Comparative Literature")+(Major="Drama")+(Major="Education")+(Major="English")+(Major="F
> ilm Studies")+(Major="French")+(Major="Government")+(Major="Health > Policy")+(Major="History")+(Major="Humanities")+(Major="Human Development & [quoted text clipped - 19 lines] > > Best, Dluxe Dluxe - 01 Mar 2005 16:58 GMT Bob,
so am I correct in that if I include an array within one of the 'sections' of the formula, the others must have arrays as well?
I was really hoping it was as easy as: =SUMPRODUCT((--(Decision={stuff}))+(other condition)*(other condition)).
That's part of the reason I thought a lookup table might help. A table of all majors with a code next to them that assigns them to a group. The sumproduct would then look something like this: =SUMPRODUCT((Major=(LOOKUP(SomeCells,SOMECODE))*(other condition)*(Other condition))
But I couldnt get that to work either... And even the Excel bible didn't have it *gasp*!!
Thoughts? B
> The problem is that your comparison arrays are different sizes, screwing up > the formula. [quoted text clipped - 5 lines] > Economics","Economics","Finance","Inter'l Economic Policy","Monetary & > Financial Policy","Public Economics"})*(Decision={"BA","BA","BA","BA","BA","BC","BC","BC","BC","BC"})*
> (Round={"1","1","1","1","1","1","1","1","1","1"})) > [quoted text clipped - 11 lines] > > Studies")+(Major="Chinese")+(Major="Classics")+(Major="Classical > > Studies")+(Major="Communication Theory")+(Major="Comparative Literature")+(Major="Drama")+(Major="Education")+(Major="English")+(Major="F
> > ilm Studies")+(Major="French")+(Major="Government")+(Major="Health > > Policy")+(Major="History")+(Major="Humanities")+(Major="Human Development > & > > Education")+(...etc..)+(Major="Visual Studies")+(Major="War and Peace Studies"))*((Decision="BA")+(Decision="BB")+(Decision="BC"))*(Round="1"))
> > Some of these formulas are getting too long for excel. I posted asking if > a [quoted text clipped - 16 lines] > > > > Best, Dluxe Bob Phillips - 01 Mar 2005 17:37 GMT If you look at the way SUMPRODUCT evaluates, it needs similar sized arrays to do the SP on, as it multiples each element of each condition by its relative element of the other condition arrays. Thus, if you have 10 comparison elements in condition 1, you need 10 in condition 2. But it is not that simple either, because you need corresponding items for each condition. So, if condition 1 has 3 comparison items, condition 2 has 2, and condition 3 has 4, then each comparison needs 24 elements (2x3x4) so as to be able to evaluate every combination.
There may be another way of doing it, but I don't about it.
 Signature HTH
RP (remove nothere from the email address if mailing direct)
> Bob, > [quoted text clipped - 24 lines] > > Economics","Economics","Finance","Inter'l Economic Policy","Monetary & > > Financial Policy","Public Economics"})*(Decision={"BA","BA","BA","BA","BA","BC","BC","BC","BC","BC"})*
> > (Round={"1","1","1","1","1","1","1","1","1","1"})) > > [quoted text clipped - 11 lines] > > > Studies")+(Major="Chinese")+(Major="Classics")+(Major="Classical > > > Studies")+(Major="Communication Theory")+(Major="Comparative Literature")+(Major="Drama")+(Major="Education")+(Major="English")+(Major="F
> > > ilm Studies")+(Major="French")+(Major="Government")+(Major="Health > > > Policy")+(Major="History")+(Major="Humanities")+(Major="Human [quoted text clipped - 26 lines] > > > > > > Best, Dluxe Debra Dalgleish - 01 Mar 2005 14:17 GMT You could use DSUM. Type lists of your subjects, decisions, etc. Then, create a category area in which you test the first row of data against the lists. Leave the criteria area heading row blank, and in the cell below, use COUNTIF formulas to test the data, e.g.:
<blank> <blank> Round =COUNTIF($N$2:$N$30,E2) =COUNTIF($O$2:$O$3,B2) 1
In this example, the subject list is in cells N2:N30, and the subject is in column E of the main table.
Then, enter a DSUM formula that refers to the database, the column you want to sum, and the criteria area:
=DSUM(Database,"Units",K1:L2)
> Hi all. > [quoted text clipped - 33 lines] > > Best, Dluxe
 Signature Debra Dalgleish Excel FAQ, Tips & Book List http://www.contextures.com/tiptech.html
Dluxe - 01 Mar 2005 17:16 GMT Debra,
Thanks... Your answer seems to describe the kind of approach I was envisioning with LOOKUPS. Though I'm still not clear how to proceed.
Can you clarify just a little on your message below. I'm a little unclear on how the 'reference table' is set up.
Thanks, Me
> You could use DSUM. Type lists of your subjects, decisions, etc. > Then, create a category area in which you test the first row of data [quoted text clipped - 25 lines] > > Studies")+(Major="Chinese")+(Major="Classics")+(Major="Classical > > Studies")+(Major="Communication Theory")+(Major="Comparative Literature")+(Major="Drama")+(Major="Education")+(Major="English")+(Major="F
> > ilm Studies")+(Major="French")+(Major="Government")+(Major="Health > > Policy")+(Major="History")+(Major="Humanities")+(Major="Human Development & > > Education")+(...etc..)+(Major="Visual Studies")+(Major="War and Peace Studies"))*((Decision="BA")+(Decision="BB")+(Decision="BC"))*(Round="1"))
> > Some of these formulas are getting too long for excel. I posted asking if a > > lookup function was the right way to fix it... A reply suggested the [quoted text clipped - 14 lines] > > > > Best, Dluxe Debra Dalgleish - 01 Mar 2005 18:22 GMT I've added a sample file to my website, that will show you how you can set up the sheet. The criteria area and lists could be on separate sheets.
http://www.contextures.com/excelfiles.html
Under Functions, look for 'Database Functions'
> Debra, > [quoted text clipped - 73 lines] >>> >>>Best, Dluxe
 Signature Debra Dalgleish Excel FAQ, Tips & Book List http://www.contextures.com/tiptech.html
|
|
|