Comments on: (3Excel)*(2Help)*(1Please)
http://ask.metafilter.com/131355/3Excel2Help1Please/
Comments on Ask MetaFilter post (3Excel)*(2Help)*(1Please)Fri, 28 Aug 2009 08:45:43 -0800Fri, 28 Aug 2009 08:45:43 -0800en-ushttp://blogs.law.harvard.edu/tech/rss60Question: (3Excel)*(2Help)*(1Please)
http://ask.metafilter.com/131355/3Excel2Help1Please
MathFilter, NumericSimplificationFilter, RecursionFilter, ExcelFilter: Where X_1,X_2,...,X_n can be any number, is there a name, simplified series, or equation to describe: (X_1)+(X_1+X_2)+(X_1+X_2+X_3)+...+(X_1+X_2+...+X_n) ? Seriously seriously insane exel implementation question inside. <br /><br /> The prior question probably gives me enough information that I can do some research on the implementation of what I'm asking below. Effectively I'm doing an accumulation of data in Excel.<br>
<br>
For each data set, I have a row containing distinct quantities<br>
We'll say that says{A1:D1} contain the values {100 | 500 | 200 | 300 }<br>
What I need {A2:D2} to say is the cumulative value of the prior cells, plus the cumulative value of the prior cumulative values<br>
<br>
This means {A2:D2} = {100 | 700 | 1500 | 2600 } is my desired result.<br>
<br>
METHOD 1.<br>
{A2} =Sum($A1:A1)<br>
{B2} =Sum($A1:B1,A2)<br>
{C2} =Sum($A1:C1,B2)<br>
{D2} =Sum($A1:D1,C2)<br>
<br>
METHOD 2.<br>
I could also represent each of these as<br>
{A2} =Sum((A1*1))<br>
{B2} =Sum((2*A1),(B1*1))<br>
{C2} =Sum((3*A1),(B1*2),(C1*1))<br>
{D2} =Sum((4*A1),{B1*3),(C1*2),(D1*1))<br>
<br>
Now here's the thing I'm not doing this to D2, I'm doing this more likely to {BB2}. I need a way (preferably without macros) to get a cleaner table. Is there a relatively simple expression so that I could generate {BB2} without generating {A2:BA2}? With the amount of data I'm performing this on, METHOD 1 requires a lot of cell real estate, and METHOD 2 results in an insanely long, quasi recursive forumula that doesn't lend itself to copying and re-use.<br>
<br>
Understand the portability of copying and re-use are the big needs, as I don't do this once, I do this a couple hundred times on data sets of varying length.... generally for 63+ columns and 200-300 entry rows...<br>
<br>
I'm hoping that by getting a better name and notation for the series that I can figure out a better way to implement this. Also, eventually this gets ported to SQL, so while recursive realities are nice, the DB admin hates 5 hour tablebuilds...post:ask.metafilter.com,2009:site.131355Fri, 28 Aug 2009 08:41:37 -0800NanukthedogMathMathematicsSimplificationRecusionExcelBy: Commander Rachek
http://ask.metafilter.com/131355/3Excel2Help1Please#1876913
I confess I didn't read the inside portion of your question very closely, but in answer to the outside portion:<br>
<br>
Wouldn't that just be n*X_1 + (n-1)*X_2 + (n-2)*X_3 + ... + X_n ?comment:ask.metafilter.com,2009:site.131355-1876913Fri, 28 Aug 2009 08:45:43 -0800Commander RachekBy: bfranklin
http://ask.metafilter.com/131355/3Excel2Help1Please#1876917
In B2:<br>
=SUM($A$1:B1)+SUM($A$2:A$2)<br>
<br>
Copy along.comment:ask.metafilter.com,2009:site.131355-1876917Fri, 28 Aug 2009 08:48:23 -0800bfranklinBy: bfranklin
http://ask.metafilter.com/131355/3Excel2Help1Please#1876923
Oh, nevermind. I see that I misunderstood you and this is basically your method 1.comment:ask.metafilter.com,2009:site.131355-1876923Fri, 28 Aug 2009 08:51:59 -0800bfranklinBy: bfranklin
http://ask.metafilter.com/131355/3Excel2Help1Please#1876924
Slightly less processor intensive: B2 is =2*A2+B1comment:ask.metafilter.com,2009:site.131355-1876924Fri, 28 Aug 2009 08:53:42 -0800bfranklinBy: milestogo
http://ask.metafilter.com/131355/3Excel2Help1Please#1876927
yes, Commander Rachek has it. The simplest equation for your {BB2} is =n*X_1 + (n-1)*X_2 + (n-2)*X_3 + ... + X_n.comment:ask.metafilter.com,2009:site.131355-1876927Fri, 28 Aug 2009 08:57:22 -0800milestogoBy: Commander Rachek
http://ask.metafilter.com/131355/3Excel2Help1Please#1876933
Upon closer inspection I see that what I outlined is your Method 2. Unfortunately for you, I believe that is the best explicit (non-recursive) representation you're going to get. Surely Excel has some way to automate that?comment:ask.metafilter.com,2009:site.131355-1876933Fri, 28 Aug 2009 09:03:17 -0800Commander RachekBy: Nanukthedog
http://ask.metafilter.com/131355/3Excel2Help1Please#1876934
Not that I've found yet, Commander Rachek. Its bloody hellish for huge datasets ....comment:ask.metafilter.com,2009:site.131355-1876934Fri, 28 Aug 2009 09:04:25 -0800NanukthedogBy: Dr Dracator
http://ask.metafilter.com/131355/3Excel2Help1Please#1876943
Can't you use an extra row for intermediate sums? I would use something like this:<br>
<br>
<pre><br>
| A | B | C | D | ...<br>
____________________________________________________________<br>
1| X1 | X2 | X3 | X4 | ... <br>
2| SUM(A1:A1) | SUM(A1:B1) | SUM(A1:C1)| SUM (A1:D1) | ...<br>
3| SUM(A2:A2) | SUM(A2:B2) | SUM(A2:C2)| SUM (A2:D2) | ...<br>
</pre>comment:ask.metafilter.com,2009:site.131355-1876943Fri, 28 Aug 2009 09:13:58 -0800Dr DracatorBy: Dr Dracator
http://ask.metafilter.com/131355/3Excel2Help1Please#1876946
Oh, as for terminology, if X1,X2... is a sequence, X1+X2+... is an infinite series and X1, (X1+x2),... is called the sequence of partial sums but I doubt you will find this useful.comment:ask.metafilter.com,2009:site.131355-1876946Fri, 28 Aug 2009 09:20:10 -0800Dr DracatorBy: Johnny Assay
http://ask.metafilter.com/131355/3Excel2Help1Please#1876956
How about this: Create another row with the values A2 = n, A3 = n-1, A4 = n-2, etc. Put a zero in the cell A(n+1). Then use the SUMPRODUCT function:<br>
<br>
=SUMPRODUCT($A1:A1,$A2:A2-B2)<br>
<br>
I think this will work in general.comment:ask.metafilter.com,2009:site.131355-1876956Fri, 28 Aug 2009 09:27:57 -0800Johnny AssayBy: Johnny Assay
http://ask.metafilter.com/131355/3Excel2Help1Please#1876960
(This is essentially an implementation of the n*X_1 + (n-1)*X_2 + ... formula mentioned above, BTW.)comment:ask.metafilter.com,2009:site.131355-1876960Fri, 28 Aug 2009 09:30:29 -0800Johnny AssayBy: Nanukthedog
http://ask.metafilter.com/131355/3Excel2Help1Please#1877000
<em>Dr. Dracator</em>: Thanks a ton - terminology helps - you are reminding me of what to look up in 15 year old calculus and algorithm textbooks.<br>
<br>
<em>Johnny Assay</em>: I have to test that formula (head somewhat exploding from wrapping my head around a meeting), but I'm thinking that may be the best implementation for my use because I can do it with fewer intermediates than you think I need using some COUNTIFS.comment:ask.metafilter.com,2009:site.131355-1877000Fri, 28 Aug 2009 10:02:21 -0800NanukthedogBy: Nanukthedog
http://ask.metafilter.com/131355/3Excel2Help1Please#1877030
Just checked it... Wow - you just made my life <em>much </em>easier <strong>Johnny Assay</strong>.comment:ask.metafilter.com,2009:site.131355-1877030Fri, 28 Aug 2009 10:33:34 -0800NanukthedogBy: Johnny Assay
http://ask.metafilter.com/131355/3Excel2Help1Please#1877095
Glad to be of help. If you don't want that last zero to be in the second row (to maximize elegance or make a square array or whatever), you can also use =SUMPRODUCT($A1:A1, $A2:A2 - A2 + 1).comment:ask.metafilter.com,2009:site.131355-1877095Fri, 28 Aug 2009 11:43:20 -0800Johnny AssayBy: Dr Dracator
http://ask.metafilter.com/131355/3Excel2Help1Please#1878478
<i>Dr. Dracator: Thanks a ton - terminology helps...</i><br>
<br>
It's great to be helpful even when one's brain is disconnected. You have probably realized by now that <a href="http://ask.metafilter.com/131355/3Excel2Help1Please#1876943">my suggestion</a> above is highly suboptimal, though it can be rewritten to be non-horrendous:<br>
<br>
<pre><br>
| A | B | C | D | ...<br>
____________________________________________________________<br>
1| X1 | X2 | X3 | X4 | ... <br>
2| =A1 | =A2+B1 | =B2+C1| =C2+D1 | ...<br>
3| =A2 | =A3+B2 | =B3+C2| =C3+D2 | ...<br>
</pre><br>
<br>
Reasonably clean, and amenable to copying-pasting and range extension.comment:ask.metafilter.com,2009:site.131355-1878478Sun, 30 Aug 2009 01:09:00 -0800Dr DracatorBy: Nanukthedog
http://ask.metafilter.com/131355/3Excel2Help1Please#1878664
So the reason why the SUMPRODUCT works the best for my needs:<br>
By shortening or lengthening the range, I can autocalculate one cell's result independent of all the others, and actually independent of the reverse index (I need not finish on 1).<br>
<br>
This means that if I want to calc on A:BB I can, as well as on F:AI with relative ease.<br>
This means that I can easily compare 1 datapoint from multiple starting locations with minimal effort - meaning that the versatility, re-usability, and reapplication of the result is extremely high.comment:ask.metafilter.com,2009:site.131355-1878664Sun, 30 Aug 2009 09:48:14 -0800Nanukthedog