Home

Tables are fantastic but cumulative totals are a pain

%3CLINGO-SUB%20id%3D%22lingo-sub-11879%22%20slang%3D%22en-US%22%3ETables%20are%20fantastic%20but%20cumulative%20totals%20are%20a%20pain%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-11879%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%3E%3CIMG%20%2F%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20468px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F3502i35C1AEC255A55320%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22StackedTables.jpg%22%20title%3D%22StackedTables.jpg%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3ECumulative%20Totals%20in%20Tables%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EExcel%20Tables%20have%20too%20many%20benefits%20to%20list%20here%2C%20if%20you've%20never%20used%20them%20then%20check%20out%20my%20article%20here%3C%2FP%3E%3CP%3E%3CA%20href%3D%22http%3A%2F%2Fwww.linkedin.com%2Fpulse%2Fwhy-dont-excel-users-know-wyn-hopkins%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ETables%20%3D%20Ctrl%20%2BT%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOne%20frustration%20I%20do%20have%20though%20is%20that%20cumulative%20totals%20in%20a%20column%20are%20not%20straightforward.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20%22normal%22%20Excel%20to%20get%20a%20running%20total%20you%20just%20add%20the%20cell%20above%20to%20the%20cell%20on%20the%20current%20row%2C%20and%20that's%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20a%20table%2C%20with%20it's%20structured%20references%20and%20headings%20this%20proves%20problematic.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAlso%2C%20ideally%20you%20want%20a%20running%20total%20that%20works%20when%20you%20insert%20rows%20into%20the%20Table%20or%20add%20lines%20of%20data%20to%20the%20bottom%20of%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%20So%20here%20are%202%20options%2C%20and%20both%20make%20use%20of%20the%20INDEX%20function.%3C%2FP%3E%3CP%3EINDEX%20has%20several%20uses%20and%20one%20of%20them%20is%20to%20make%20a%20dynamic%20range.%3C%2FP%3E%3CP%3EThis%20is%20a%20very%20odd%20concept%20when%20you%20first%20see%20it%20written%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ee.g.%20%3DSUM(A1%3AA10)%20can%20be%20re-written%20with%20an%20INDEX%20formula%20as%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3D%20SUM(%20INDEX(A%3AA%20%2C%201)%3CSTRONG%3E%20%3A%3C%2FSTRONG%3E%20INDEX(A%3AA%20%2C%2010)%20)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EEssentially%20it's%20saying%20SUM%20everything%20between%20the%201st%20cell%20of%20A%3AA%20and%20the%2010th%20cell%20of%20A%3AA%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EStick%20with%20me%2C%20like%20I%20say%2C%20I%20know%20it's%20unfamiliar%20and%20a%20little%20weird.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELet's%20apply%20this%20to%20a%20Table%20that%20has%20weekly%20units%20sold%20for%20January%20and%20February%3C%2FP%3E%3CP%3ETo%20keep%20things%20simple%20I've%20set%20it%20so%20that%20we've%20sold%201%20unit%20a%20week.%3C%2FP%3E%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fmedia.licdn.com%2Fmpr%2Fmpr%2FAAEAAQAAAAAAAAfGAAAAJGExYzEzMjQwLWM1NzAtNDMyMC04ZDlkLWEwZmE5NDI4NGY1NA.png%22%20border%3D%220%22%20%2F%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20the%20formula%20we%20put%20in%20the%20Cumulative%20Sum%20column%20is%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DSUM(%20INDEX(%20%5BUnits%20Sold%5D%20%2C%201)%20%3A%20%5B%40%5BUnits%20Sold%5D%5D)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20it%20adds%20up%20the%20values%20from%20row%201%20of%20the%20Units%20Sold%20column%20as%20far%20as%20each%20row%20(that's%20where%20the%20%40%20%5BUnits%20Sold%5D%20comes%20in)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'll%20agree%20it's%20not%20a%20very%20attractive%20formula%20but%20it%20works%20and%20I%20wish%20there%20was%20a%20simpler%20way.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CBLOCKQUOTE%3EImportantly%20it%20works%20if%20you%20insert%20rows%20or%20add%20more%20data%20to%20the%20bottom%20of%20the%20Table.%20Brilliant!%3C%2FBLOCKQUOTE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EOption%202%20%3A%20A%20little%20more%20advanced%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you've%20stuck%20with%20me%20this%20far%20then%20it's%20worth%20reading%20this%20extra%20bit...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20SUM%20approach%20has%20a%20drawback.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20filter%20the%20table%20for%20February%20you%20still%20get%20the%20YTD%20cumulative%20rather%20than%20just%20the%20February%20Cumulative%3C%2FP%3E%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fmedia.licdn.com%2Fmpr%2Fmpr%2FAAEAAQAAAAAAAAgcAAAAJDQ3MzgzMTBhLWE2ZmEtNDhlMy04ZGE3LWNkOWU5NzU1NWEyOQ.png%22%20border%3D%220%22%20width%3D%22744%22%20%2F%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAn%20alternative%20is%20the%20little%20known%20AGGREGATE%20function%20(you%20could%20also%20use%20SUBTOTAL).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DAGGREGATE(%209%2C%207%2C%20INDEX(%20%5BUnits%20Sold%5D%20%2C%201)%20%3A%20%5B%40%5BUnits%20Sold%5D%5D%20)%20)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%209%20means%20SUM%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%207%20means%20ignore%20Hidden%20Rows%20AND%20Errors%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20when%20the%20data%20is%20filtered%20the%20rows%20are%20hidden%2C%20and%20the%20Aggregate%20works%20nicely.%20Even%20if%20one%20of%20your%20values%20was%20an%20Error%20e.g.%20%23VALUE%20or%20DIV%2F0%20the%20cumulative%20would%20ignore%20it%20and%20the%20total%20still%20works.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20ignoring%20of%20elements%20can%20come%20in%20really%20useful%2C%20but%20just%20be%20careful%20that%20you%20really%20do%20want%20to%20do%20this!%20Spotting%20errors%20are%20normally%20a%20good%20thing.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20suggestions%20of%20alternative%20approaches%20would%20be%20appreciated.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20file%20is%20located%20here%20if%20you'd%20like%20to%20download%20it%3C%2FP%3E%3CP%3E%3CA%20href%3D%22http%3A%2F%2Fdoc.co%2Fod4vDm%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ELink%20to%20Excel%20file%20on%20DOCS.com%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20you%20find%20this%20useful%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWyn%3C%2FP%3E%3CP%3E%3CA%20href%3D%22http%3A%2F%2Fwww.linkedin.com%2Ftoday%2Fauthor%2Fwynhopkins%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EMy%20other%20Linked%20In%20articles%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CBLOCKQUOTE%3EAMAZING%20EXCEL%20SOLUTIONS%3C%2FBLOCKQUOTE%3E%3CBLOCKQUOTE%3E%3CA%20href%3D%22http%3A%2F%2Fwww.accessanalytic.com.au%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ewww.accessanalytic.com.au%3C%2FA%3E%3C%2FBLOCKQUOTE%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-11879%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ETraining%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-333343%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20Tables%20are%20fantastic%20but%20cumulative%20totals%20are%20a%20pain%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-333343%22%20slang%3D%22en-US%22%3E%3CP%3EYou%20can%20also%20do%20the%20same%20thing%20with%20an%20old-style%20CSE%20array%20formula.%26nbsp%3B%20By%20defining%20an%20offset%20range%20'PriorBalance'%20to%20do%20the%20job%20of%20your%20relative%20reference%20'RowAbove'%2C%20one%20can%20use%20formulas%20such%26nbsp%3B%3C%2FP%3E%3CP%3E%3D%20IF(%20Initialise%3F%2C%20CarriedForward%2C%26nbsp%3B%3CSPAN%3EPriorBalance%3C%2FSPAN%3E%20)%20%2B%20Credit%3C%2FP%3E%3CP%3Efor%20accumulation.%26nbsp%3B%20It%20is%20robust%20to%20any%20drag-and-drop%20that%20may%20be%20used%20to%20adjust%20the%20credit%20amounts%20and%20no%20one%20is%20going%20to%20insert%20a%20row%20through%20it!%26nbsp%3B%20Such%20formulas%20are%20out%20of%20spec%20for%20a%20modern%20dynamic%20arrays%20though.%26nbsp%3B%20Neither%20exist%20within%20the%20Table%20though.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ep.s.%20'Initialise%3F'%20simply%20holds%20the%20first%20row%20test%3C%2FP%3E%3CP%3E%3D%20PriorBalance%20%3D%22Balance%22%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-12893%22%20slang%3D%22en-US%22%3ERE%3A%20Tables%20are%20fantastic%20but%20cumulative%20totals%20are%20a%20pain%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-12893%22%20slang%3D%22en-US%22%3EFair%20point%20%40Ingeborg.%20An%20alternative%20for%20bigger%20data%20sets%20that%20can%20handle%20inserted%20%2F%20deleted%20rows%20would%20be%20this%3A%20I%20selected%20cell%20A2%20and%20then%20defined%20the%20name%20%22RowAbove%22%20as%20%3D%20N(A1)%20Then%20my%20cumulative%20formula%20in%20the%20Table%20can%20be%20set%20as%20RowAbove%20%2B%20%5B%40Units%20Sold%5D%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-12870%22%20slang%3D%22en-US%22%3ERe%3A%20Tables%20are%20fantastic%20but%20cumulative%20totals%20are%20a%20pain%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-12870%22%20slang%3D%22en-US%22%3E%3CP%3ENice%20write-up%2C%20but%20it's%20missing%20one%20essential%20thing%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EReaders%2C%20be%20aware%20that%20for%20large%20data%20sets%2C%20this%20technique%20can%20slow%20down%20Excel%20performance%20when%20the%20sheet%20is%20recalculated.%20In%20every%20row%2C%20the%20formula%20will%20sum%20from%20the%20first%20table%20data%20row%20to%20the%20current%20data%20row.%20If%20you%20only%20have%20a%20few%20hundred%20rows%2C%20that's%20still%20fast.%20But%20if%20the%20data%20set%20goes%20into%20the%20hundreds%20of%20thousands%20of%20rows%2C%20you%20will%20notice%20a%20performance%20hit.%20In%20each%20row%2C%20Excel%20has%20to%20calculate%20an%20ever%20growing%20range%20of%20cells.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20in%20each%20row%20it%20also%20adds%20numbers%20that%20have%20already%20been%20added.%20This%20is%20unnecessary%20repetition%20of%20calculation%20and%20very%20inefficient.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20a%20table%20with%20500%2C000%20rows%20there%20are%20499%2C990%20formulas.%20In%20row%203%20the%20formula%20processes%202%20cells%2C%20in%20row%204%20the%20formula%20processes%203%20cells%2C%20%5B...%5D%2C%20in%20row%20499%2C999%20it%20processes%20499%2C998%20cells%2C%20and%20in%20row%20500%2C000%20the%20formula%20processes%20499%2C999%20cells.%20That's%20a%20total%20of%20125%2C000%2C249%2C999%20to%20process%2C%20and%20that%20will%20take%20time.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EA%20faster%20approach%20can%20be%20realised%20by%20adding%20just%20the%20previous%20row's%20total%20with%20the%20current%20row's%20sold%20units.%20That%20way%2C%20each%20of%20the%20499%2C999%20formulas%20calculates%20only%20two%20cells%2C%201%20Million%20in%20total.%20Or%2C%20in%20a%20scenario%20with%20a%20debit%20and%20credit%20contributing%20to%20the%20balance%2C%20three%20cells%2C%20which%20would%20be%201%2C5%20million%20cells%20to%20process.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUnfortunately%2C%20structured%20referencing%20does%20not%20have%20a%20handle%20for%20%22the%20previous%20row%22%2C%20so%20we%20still%20need%20to%20revert%20to%20A1%20notation%20to%20do%20this.%20Consider%20the%20following%20screenshot%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20800px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F3996iF9A158A1299A188C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22TableRunningTotal.png%22%20title%3D%22TableRunningTotal.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EThe%20first%20scenario%20calculates%20the%20running%20total%20with%20this%20formula%20starting%20in%20E3%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DSUM(E2%2CD3)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20Sum()function%20ignores%20text%20values%2C%20so%20in%20the%20first%20instance%20of%20the%20formula%2C%20E2%20is%20ignored%20and%20D3%20is%20added%20to%20the%20total.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20green%20table%20has%20the%20typical%20credit%2Fdebit%20pattern%20with%20the%20current%20balance.%20Here%20the%20formula%20in%20J3%20is%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DSUM(J2%2CH3%2C-I3)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnother%20way%20to%20write%20this%20formula%20would%20be%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DN(J2)%2BH3-I3%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20plus%20and%20minus%20operators%20don't%20tolerate%20text%20and%20will%20return%20an%20error%20if%20any%20of%20the%20cells%20contain%20text.%20The%20N()%20function%20converts%20a%20cell%20value%20to%20a%20number%20and%20will%20return%200%20if%20it%20contains%20text%2C%20so%20the%20formula%20will%20not%20return%20an%20error%20in%20the%20first%20data%20row%2C%20despite%20using%20plus%20and%20minus%20operators%20and%20J2%20referring%20to%20the%20column%20title%2C%20which%20is%20text.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOne%20drawback%20with%20this%20solution%20is%20that%20when%20a%20row%20is%20inserted%20in%20the%20middle%20of%20the%20table%2C%20the%20formula%20in%20the%20inserted%20row%20will%20have%20a%20wrong%20reference.%20But%20Excel%20picks%20this%20up%20and%20sets%20the%20green%20warning%20triangle%2C%20which%20when%20clicked%20informs%20that%20the%20formula%20is%20inconsistent.%20A%20correct%20formula%20can%20quickly%20be%20restored%20by%20clicking%20the%20warning%20drop-down%20and%20selecting%20%22Restore%20to%20calculated%20column%20formula%22.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20486px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F3997iEC74B51C2F4DF2DF%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22RestoreColumn.png%22%20title%3D%22RestoreColumn.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EIn%20many%20situations%20that%20approach%26nbsp%3Bis%20faster%20than%20waiting%20for%20over%20a%20billion%20cells%20to%20be%20processed%2C%20but%20it%20can%20be%20argued%20that%20it's%20easy%20to%20miss%20the%20warning.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-544538%22%20slang%3D%22en-US%22%3ERe%3A%20Tables%20are%20fantastic%20but%20cumulative%20totals%20are%20a%20pain%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-544538%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F9832%22%20target%3D%22_blank%22%3E%40Wyn%20Hopkins%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20great%20stuff!%3C%2FP%3E%3CP%3EI%20have%20been%20struggling%20with%20references%20in%20tables%20to%20cells%20in%20previous%20rows.%20I%20have%20always%20used%20normal%20cell%20reference%20and%20that%20worked%20because%20in%20those%20particular%20cases%20I%20do%20not%20need%20to%20insert%20rows%20in%20the%20middle%20of%20the%20table%20or%20even%20sort%20the%20table.%20This%20tip%20of%20yours%20will%20be%20very%20useful%20in%20the%20future.%3C%2FP%3E%3CP%3EThank%20you%20for%20sharing%20this!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-544547%22%20slang%3D%22en-US%22%3ERe%3A%20Tables%20are%20fantastic%20but%20cumulative%20totals%20are%20a%20pain%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-544547%22%20slang%3D%22en-US%22%3EGlad%20to%20help%20%3A)%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-545390%22%20slang%3D%22en-US%22%3ERe%3A%20Tables%20are%20fantastic%20but%20cumulative%20totals%20are%20a%20pain%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-545390%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F9832%22%20target%3D%22_blank%22%3E%40Wyn%20Hopkins%3C%2FA%3E%3C%2FP%3E%3CP%3EI%20guess%20this%20article%20is%20one%20that%20will%20just%20run%20and%20run%20despite%20its%20original%20date!%3C%2FP%3E%3CP%3EA%20solution%20I%20adopted%20was%20to%20define%20a%20named%20reference%20'prior'%20that%20refers%20to%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3DSheet1!R%5B-1%5D%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3Ein%20R1C1%20notation%20(i.e.%20the%20row%20above).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20accumulation%20may%20then%20be%20expressed%20using%20Range%20intersection%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3D%20%5B%40amount%5D%20%2B%20IFERROR(prior%20%5Bbalance%5D%2C%200)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3Ewhere%20the%20error%20traps%20the%20NULL%20reference%20that%20results%20from%20applying%20the%20formula%20to%20the%20first%20row.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETo%20accumulate%20over%20a%20filtered%20set%2C%20one%20could%20introduce%20a%20helper%20column%20'selected%3F'%20to%20indicate%20whether%20the%20row%20is%20filtered%20or%20not%20(using%20a%20form%20of%20COUNT)%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3DSUBTOTAL(103%2C%5B%40amount%5D)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EThe%20accumulation%20then%20becomes%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3D%20IF(%5Bselected%3F%5D%2C%20%5B%40amount%5D%2C%200)%20%2B%20IFERROR(prior%20%5Bbalance%5D%2C%200)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThere%20remains%20the%20problem%20that%20a%20Table%20is%20designed%20to%20hold%20an%20unsorted%20list%20whereas%20accumulation%20is%20essentially%20an%20array%20operation%20(integration)%20and%20requires%20the%20terms%20to%20appear%20in%20the%20correct%20order.%26nbsp%3B%20To%20'harden'%20the%20calculation%20in%20the%20presence%20of%20Sort%20is%20another%20challenge%20since%20'prior'%20then%20has%20to%20pick%26nbsp%3B%20out%20the%20record%20that%20immediately%20precedes%20the%26nbsp%3B%20current%20record%20in%20terms%20of%20date%2C%20not%20position.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-549584%22%20slang%3D%22en-US%22%3ERe%3A%20Tables%20are%20fantastic%20but%20cumulative%20totals%20are%20a%20pain%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-549584%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F214174%22%20target%3D%22_blank%22%3E%40Peter%20Bartholomew%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20a%20lot%20for%20sharing%20this.%20It%20will%20be%20of%20great%20help%20in%20the%20future.%20Some%20of%20the%20work%20that%20I%20do%20includes%20calculators%20for%20financial%20models.%20I%20tend%20to%20use%20tables%2C%20not%20because%20I%20need%20to%20filter%20or%20sort%2C%20but%20mostly%20because%20formulas%20will%20make%20much%20more%20sense.%20Very%20often%20I%20need%20to%20refer%20to%20cells%20in%20the%20previous%20rows%20of%20the%20table.%20Next%20time%2C%20I%20will%20use%20the%20tricks%20that%20you%20both%20shared.%20%3B-)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-550264%22%20slang%3D%22en-US%22%3ERe%3A%20Tables%20are%20fantastic%20but%20cumulative%20totals%20are%20a%20pain%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-550264%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F214174%22%20target%3D%22_blank%22%3E%40Peter%20Bartholomew%3C%2FA%3E%26nbsp%3B%2C%20I%20didn't%20catch%20why%20do%20you%20need%20helper%20column.%20IMHO%2C%3C%2FP%3E%0A%3CPRE%3E%3D%20SUBTOTAL(4%2C%5B%40amount%5D)%20%2B%20IFERROR(prior%20%5Bbalance%5D%2C%200)%3C%2FPRE%3E%0A%3CP%3Eshall%20work%20(or%209%2C%20109%2C%20etc)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-550334%22%20slang%3D%22en-US%22%3ERe%3A%20Tables%20are%20fantastic%20but%20cumulative%20totals%20are%20a%20pain%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-550334%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAgreed.%26nbsp%3B%20It%20was%20just%20the%20way%20I%20developed%20the%20solution.%26nbsp%3B%20I%20should%20have%20reduced%20it%20to%20one%20of%20your%20suggested%20formulas%20rather%20just%20than%20settling%20on%20the%20first%20solution%20that%20worked.%20%3A-(%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-685123%22%20slang%3D%22en-US%22%3ERe%3A%20Tables%20are%20fantastic%20but%20cumulative%20totals%20are%20a%20pain%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-685123%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F214174%22%20target%3D%22_blank%22%3E%40Peter%20Bartholomew%3C%2FA%3E%26nbsp%3Band%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F9832%22%20target%3D%22_blank%22%3E%40Wyn%20Hopkins%3C%2FA%3E!%3C%2FP%3E%3CP%3ECould%20you%20please%20explain%20the%20steps%20in%20more%20detail%3F%3C%2FP%3E%3CP%3EWhen%20I%20try%20to%20set%20the%20name%20%3CEM%3Eprior%3C%2FEM%3E%26nbsp%3Bas%20referring%20to%26nbsp%3B%3CSTRONG%3E%3DSheet1!R%5B-1%5D%3C%2FSTRONG%3E%2C%20I%20get%20an%20error%20message%20saying%20that%20the%20formula%20is%20not%20valid.%3C%2FP%3E%3CP%3EI%20tried%26nbsp%3B%3CSTRONG%3E%3DSheet1!R%5B-1%5DC%26nbsp%3B%3C%2FSTRONG%3Ebut%20I%20got%20the%20same%20error.%3C%2FP%3E%3CP%3EIf%20I%20set%20up%20the%20name%20by%20selecting%20A2%20and%20referring%20to%20A1%20(no%20dollar%20sign)%2C%20the%20formula%20is%20accepted.%20But%20I%20cannot%20get%20it%20to%20work%20with%20the%20table%20field%20names%20as%26nbsp%3B%3CSTRONG%3Eprior%20%5Bbalance%5D%3C%2FSTRONG%3E.%20It%20will%20only%20work%20if%20I%20use%20the%20name%20alone%20(no%20table%20field%20associated)%20to%20refer%20to%20the%20previous%20row%20on%20the%20same%20column.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20clarification%2Fhelp%20would%20be%20very%20much%20appreciated.%26nbsp%3B%3C%2FP%3E%3CP%3EThanks!%20%3A)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-686858%22%20slang%3D%22en-US%22%3ERe%3A%20Tables%20are%20fantastic%20but%20cumulative%20totals%20are%20a%20pain%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-686858%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F302344%22%20target%3D%22_blank%22%3E%40Celia_Alves%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20410px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F117886i79BD1D3E059145CF%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20the%20R%5B-1%5D%20method%20I%20may%20be%20wrong%20but%20I%20think%20you%20have%20to%20go%20to%20Options%20%26gt%3B%20Formulas%20and%20set%20it%20to%20R1C1%20method%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-687148%22%20slang%3D%22en-US%22%3ERe%3A%20Tables%20are%20fantastic%20but%20cumulative%20totals%20are%20a%20pain%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-687148%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F302344%22%20target%3D%22_blank%22%3E%40Celia_Alves%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ER1C1%20notation%20is%20more%20suitable%20and%20more%20natural%20for%20named%20relative%20reference.%20Not%20necessary%20to%20think%20about%20implicit%20intersection.%20However%2C%20that%20works%20fine%20in%20A1%20notation%20as%20well.%3C%2FP%3E%0A%3CP%3EIn%20A1%20notation%20exactly%20the%20same%20will%20be%20if%2C%20for%20example%2C%20you%20stay%20on%20cell%20A2%20and%20add%20named%20reference%20RowAbove%20as%3C%2FP%3E%0A%3CPRE%3E%3DSheet1!A1%3C%2FPRE%3E%0A%3CP%3Ewith%20relative%20references.%20You%20may%20stay%20now%20on%20any%20other%20cell%2C%20let%20say%20K5%20and%20check%20in%20name%20manager%20what%20is%20the%20formula%20for%20RowAbove%20-%20now%20it%20will%20show%20Sheet1!K4.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESame%20for%20any%20other%20relative%20references.%20It's%20important%20to%20take%20into%20account%20where%20do%20you%20stay%20adding%20such%20named%20references.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-687299%22%20slang%3D%22en-US%22%3ERe%3A%20Tables%20are%20fantastic%20but%20cumulative%20totals%20are%20a%20pain%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-687299%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F302344%22%20target%3D%22_blank%22%3E%40Celia_Alves%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20rarely%2C%20if%20ever%2C%20use%20a%20direct%20cell%20reference%2C%20so%20it%20makes%20little%20difference%20to%20me%20whether%20my%20workbook%20is%20set%20to%20the%20familiar%20A1%20notation%20or%20the%20earlier%20R1C1%20notation.%26nbsp%3B%20Why%20I%20chose%20to%20use%20it%20here%20is%20that%20it%20is%20less%20ambiguous.%26nbsp%3B%20If%20your%20calculation%20is%20set%20to%20R1C1%2C%3C%2FP%3E%3CP%3E%3CSPAN%3E%3DSheet1!R%5B-1%5D%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3Eis%20a%20formula%20that%20references%20the%20entire%20row%20immediately%20above%20the%20active%20cell%20with%20the%20formula.%26nbsp%3B%20If%20you%20switch%20to%20A1%20notation%2C%20the%20reference%20will%20need%20to%20be%20defined%20as%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CSPAN%3E%3DSheet1!9%3A9%20%3C%2FSPAN%3Eif%20the%20active%20cell%20is%20in%20row%2010%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CSPAN%3E%3DSheet1!10%3A10%3C%2FSPAN%3E%20if%20the%20active%20cell%20is%20in%20row%2011%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3Eetc.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EThis%20definition%20(with%20an%20adjective%20used%20as%20a%20name)%20is%20made%20with%20an%20eye%20on%20generating%20readable%20formulas%2C%20%3CEM%3Ee.g%3C%2FEM%3E.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CSPAN%3E%3D%20prior%20%5Bbalance%5D%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSPAN%3Eis%20the%20intersection%20of%20the%20row%20above%20the%20formula%20and%20the%20%5Bbalance%5D%20column%20(any%20two%20range%20references%20separated%20by%20a%20space%20will%20return%20the%20intersection).%26nbsp%3B%20Since%20the%20row%20prior%20intersects%20all%20of%20the%20columns%20of%20the%20table%2C%20one%20could%20also%20use%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CSPAN%3E%3D(prior%20%5Bdate%5D)%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSPAN%3Eto%20give%20the%20date%20of%20the%20previous%20transactions.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EIf%20your%20workbook%20is%20sufficiently%20small%20that%20you%20can%20afford%20to%20use%20volatile%20functions%2C%20then%20you%20could%2C%20as%20an%20alternative%2C%20define%20'prior'%20by%20the%20formula%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CSPAN%3E%3DOFFSET(Table1%5B%40%5D%2C-1%2C0)%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CEM%3Ei.e.%3C%2FEM%3E%20the%20table%20row%20above%20the%20current%20one.%26nbsp%3B%20Sample%20formulas%20might%20include%20the%20following%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CSPAN%3E%3D%20IF(%20ISREF(prior%20Table1%5B%23Headers%5D)%2C%20%22%22%2C%20%5B%40Date%5D%20-%20(prior%20%5BDate%5D)%20)%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSPAN%3Efor%20the%20interval%20between%20two%20transactions%20(could%20be%20of%20relevance%20if%20you%20are%20fortunate%20enough%20to%20accrue%20interest%20on%20current%20balances)%20or%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CSPAN%3E%3D%20IF(%20ISREF(prior%20Table1%5B%23Headers%5D)%2C%20BFwd%2C%20%5B%40Amount%5D%20%2B%20(prior%20%5BBalance%5D)%20)%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSPAN%3Efor%20a%20running%20balance.%26nbsp%3B%20Here%20the%20first%20row%20will%20be%20characterised%20by%20the%20range%20'prior'%20coinciding%20with%20the%20%5B%23Headers%5D%20row%20so%2C%20instead%20of%20generating%20an%20error%2C%20the%20formula%20will%20reference%20the%20'balance%20brought%20forward'.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EWill%20your%20colleagues%20be%20able%20to%20read%20your%20formulas%3F%26nbsp%3B%20They%20will%20be%20able%20to%20deduce%20the%20intent%20but%20they%20would%20run%20a%20mile%20if%20you%20suggested%20they%20should%20take%20responsibility%20for%20the%20workbook!%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-723018%22%20slang%3D%22en-US%22%3ERe%3A%20Tables%20are%20fantastic%20but%20cumulative%20totals%20are%20a%20pain%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-723018%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F214174%22%20target%3D%22_blank%22%3E%40Peter%20Bartholomew%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eneed%20help.%3C%2FP%3E%3CP%3Ewe%20have%20inventory%20movement%26nbsp%3Btable%20for%26nbsp%3Bvarious%20stock%20items%20with%20stock%26nbsp%3B%26nbsp%3BIn%20and%20Out%20information.%3C%2FP%3E%3CP%3EI%20am%20try%20to%20create%20a%20pivot%20report%2C%20where%20we%20can%20new%20fields%20to%20table%20such%20as%20opening%20balance%2C%20running%20balance%20and%20closing%20balance%20for%20any%20given%20point%20in%20a%20time.%3C%2FP%3E%3CP%3Ecan%20someone%20help%2C%20how%20to%20write%20a%20formula%20for%20opening%20balance%2C%20running%20balance%20and%20closing%20balance.%3C%2FP%3E%3CP%3Esee%20attached%20spreadsheet%20for%20example%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-724633%22%20slang%3D%22en-US%22%3ERe%3A%20Tables%20are%20fantastic%20but%20cumulative%20totals%20are%20a%20pain%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-724633%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F367370%22%20target%3D%22_blank%22%3E%40Sam_3026%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUnless%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F9832%22%20target%3D%22_blank%22%3E%40Wyn%20Hopkins%3C%2FA%3E%20wishes%20your%20question%20to%20be%20dealt%20with%20here%2C%20I%20suggest%20you%20open%20a%20new%20thread.%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20also%20observe%20that%20since%20there%20are%20some%20of%20the%20most%20competent%20Excel%20practitioners%20worldwide%20responding%20to%20this%20thread%20it%20would%20be%20a%20mistake%20to%20narrow%20your%20potential%20solutions%20to%20a%20specific%20approach.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-724748%22%20slang%3D%22en-US%22%3ERe%3A%20Tables%20are%20fantastic%20but%20cumulative%20totals%20are%20a%20pain%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-724748%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F367370%22%20target%3D%22_blank%22%3E%40Sam_3026%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYes%20if%20you%20could%20just%20post%20a%20new%20item%20to%20the%20community%20about%20this%20that%20would%20be%20great.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%40%26nbsp%3B%20%26nbsp%3Bus%20in%20if%20you%20like%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECheers%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWyn%3C%2FP%3E%3C%2FLINGO-BODY%3E
Wyn Hopkins
MVP

StackedTables.jpgCumulative Totals in Tables

Excel Tables have too many benefits to list here, if you've never used them then check out my article here

Tables = Ctrl +T

 

One frustration I do have though is that cumulative totals in a column are not straightforward.

 

In "normal" Excel to get a running total you just add the cell above to the cell on the current row, and that's it.

 

For a table, with it's structured references and headings this proves problematic.

 

Also, ideally you want a running total that works when you insert rows into the Table or add lines of data to the bottom of it.

  So here are 2 options, and both make use of the INDEX function.

INDEX has several uses and one of them is to make a dynamic range.

This is a very odd concept when you first see it written

 

e.g. =SUM(A1:A10) can be re-written with an INDEX formula as

 

= SUM( INDEX(A:A , 1) : INDEX(A:A , 10) )

 

Essentially it's saying SUM everything between the 1st cell of A:A and the 10th cell of A:A

 

Stick with me, like I say, I know it's unfamiliar and a little weird.

 

Let's apply this to a Table that has weekly units sold for January and February

To keep things simple I've set it so that we've sold 1 unit a week.

 

So the formula we put in the Cumulative Sum column is

 

=SUM( INDEX( [Units Sold] , 1) : [@[Units Sold]])

 

So it adds up the values from row 1 of the Units Sold column as far as each row (that's where the @ [Units Sold] comes in)

 

I'll agree it's not a very attractive formula but it works and I wish there was a simpler way.

 

Importantly it works if you insert rows or add more data to the bottom of the Table. Brilliant!

 

Option 2 : A little more advanced

 

If you've stuck with me this far then it's worth reading this extra bit...

 

The SUM approach has a drawback.

 

If you filter the table for February you still get the YTD cumulative rather than just the February Cumulative

 

An alternative is the little known AGGREGATE function (you could also use SUBTOTAL).

 

=AGGREGATE( 9, 7, INDEX( [Units Sold] , 1) : [@[Units Sold]] ) )

 

The 9 means SUM

 

The 7 means ignore Hidden Rows AND Errors

 

So when the data is filtered the rows are hidden, and the Aggregate works nicely. Even if one of your values was an Error e.g. #VALUE or DIV/0 the cumulative would ignore it and the total still works.

 

This ignoring of elements can come in really useful, but just be careful that you really do want to do this! Spotting errors are normally a good thing.

 

Any suggestions of alternative approaches would be appreciated.

 

The file is located here if you'd like to download it

Link to Excel file on DOCS.com

 

Hope you find this useful

 

Wyn

My other Linked In articles

 

AMAZING EXCEL SOLUTIONS
www.accessanalytic.com.au
16 Replies
Highlighted

Nice write-up, but it's missing one essential thing:

 

Readers, be aware that for large data sets, this technique can slow down Excel performance when the sheet is recalculated. In every row, the formula will sum from the first table data row to the current data row. If you only have a few hundred rows, that's still fast. But if the data set goes into the hundreds of thousands of rows, you will notice a performance hit. In each row, Excel has to calculate an ever growing range of cells.

 

But in each row it also adds numbers that have already been added. This is unnecessary repetition of calculation and very inefficient.

 

In a table with 500,000 rows there are 499,990 formulas. In row 3 the formula processes 2 cells, in row 4 the formula processes 3 cells, [...], in row 499,999 it processes 499,998 cells, and in row 500,000 the formula processes 499,999 cells. That's a total of 125,000,249,999 to process, and that will take time.

 

A faster approach can be realised by adding just the previous row's total with the current row's sold units. That way, each of the 499,999 formulas calculates only two cells, 1 Million in total. Or, in a scenario with a debit and credit contributing to the balance, three cells, which would be 1,5 million cells to process.

 

Unfortunately, structured referencing does not have a handle for "the previous row", so we still need to revert to A1 notation to do this. Consider the following screenshot:

 

TableRunningTotal.png

The first scenario calculates the running total with this formula starting in E3:

 

=SUM(E2,D3)

 

The Sum()function ignores text values, so in the first instance of the formula, E2 is ignored and D3 is added to the total.

 

The green table has the typical credit/debit pattern with the current balance. Here the formula in J3 is

 

=SUM(J2,H3,-I3)

 

Another way to write this formula would be

 

=N(J2)+H3-I3

 

The plus and minus operators don't tolerate text and will return an error if any of the cells contain text. The N() function converts a cell value to a number and will return 0 if it contains text, so the formula will not return an error in the first data row, despite using plus and minus operators and J2 referring to the column title, which is text.

 

One drawback with this solution is that when a row is inserted in the middle of the table, the formula in the inserted row will have a wrong reference. But Excel picks this up and sets the green warning triangle, which when clicked informs that the formula is inconsistent. A correct formula can quickly be restored by clicking the warning drop-down and selecting "Restore to calculated column formula".

 

RestoreColumn.png

In many situations that approach is faster than waiting for over a billion cells to be processed, but it can be argued that it's easy to miss the warning. 

Fair point @Ingeborg. An alternative for bigger data sets that can handle inserted / deleted rows would be this: I selected cell A2 and then defined the name "RowAbove" as = N(A1) Then my cumulative formula in the Table can be set as RowAbove + [@Units Sold]

You can also do the same thing with an old-style CSE array formula.  By defining an offset range 'PriorBalance' to do the job of your relative reference 'RowAbove', one can use formulas such 

= IF( Initialise?, CarriedForward, PriorBalance ) + Credit

for accumulation.  It is robust to any drag-and-drop that may be used to adjust the credit amounts and no one is going to insert a row through it!  Such formulas are out of spec for a modern dynamic arrays though.  Neither exist within the Table though.

 

p.s. 'Initialise?' simply holds the first row test

= PriorBalance ="Balance"

@Wyn Hopkins 

This is great stuff!

I have been struggling with references in tables to cells in previous rows. I have always used normal cell reference and that worked because in those particular cases I do not need to insert rows in the middle of the table or even sort the table. This tip of yours will be very useful in the future.

Thank you for sharing this!

@Wyn Hopkins

I guess this article is one that will just run and run despite its original date!

A solution I adopted was to define a named reference 'prior' that refers to

=Sheet1!R[-1]

in R1C1 notation (i.e. the row above).

 

The accumulation may then be expressed using Range intersection

= [@amount] + IFERROR(prior [balance], 0)

where the error traps the NULL reference that results from applying the formula to the first row.

 

To accumulate over a filtered set, one could introduce a helper column 'selected?' to indicate whether the row is filtered or not (using a form of COUNT)

=SUBTOTAL(103,[@amount])

The accumulation then becomes

= IF([selected?], [@amount], 0) + IFERROR(prior [balance], 0)

 

There remains the problem that a Table is designed to hold an unsorted list whereas accumulation is essentially an array operation (integration) and requires the terms to appear in the correct order.  To 'harden' the calculation in the presence of Sort is another challenge since 'prior' then has to pick  out the record that immediately precedes the  current record in terms of date, not position.

@Peter Bartholomew 

Thanks a lot for sharing this. It will be of great help in the future. Some of the work that I do includes calculators for financial models. I tend to use tables, not because I need to filter or sort, but mostly because formulas will make much more sense. Very often I need to refer to cells in the previous rows of the table. Next time, I will use the tricks that you both shared. ;-)

@Peter Bartholomew , I didn't catch why do you need helper column. IMHO,

= SUBTOTAL(4,[@amount]) + IFERROR(prior [balance], 0)

shall work (or 9, 109, etc)

 

@Sergei Baklan 

Agreed.  It was just the way I developed the solution.  I should have reduced it to one of your suggested formulas rather just than settling on the first solution that worked. :-(

Hi, @Peter Bartholomew and @Wyn Hopkins!

Could you please explain the steps in more detail?

When I try to set the name prior as referring to =Sheet1!R[-1], I get an error message saying that the formula is not valid.

I tried =Sheet1!R[-1]C but I got the same error.

If I set up the name by selecting A2 and referring to A1 (no dollar sign), the formula is accepted. But I cannot get it to work with the table field names as prior [balance]. It will only work if I use the name alone (no table field associated) to refer to the previous row on the same column.

 

Any clarification/help would be very much appreciated. 

Thanks! :)

 

 

@Celia_Alves 

 

image.png

 

 

With the R[-1] method I may be wrong but I think you have to go to Options > Formulas and set it to R1C1 method

@Celia_Alves 

 

R1C1 notation is more suitable and more natural for named relative reference. Not necessary to think about implicit intersection. However, that works fine in A1 notation as well.

In A1 notation exactly the same will be if, for example, you stay on cell A2 and add named reference RowAbove as

=Sheet1!A1

with relative references. You may stay now on any other cell, let say K5 and check in name manager what is the formula for RowAbove - now it will show Sheet1!K4.

 

Same for any other relative references. It's important to take into account where do you stay adding such named references.

 

@Celia_Alves 

I rarely, if ever, use a direct cell reference, so it makes little difference to me whether my workbook is set to the familiar A1 notation or the earlier R1C1 notation.  Why I chose to use it here is that it is less ambiguous.  If your calculation is set to R1C1,

=Sheet1!R[-1]

is a formula that references the entire row immediately above the active cell with the formula.  If you switch to A1 notation, the reference will need to be defined as

=Sheet1!9:9 if the active cell is in row 10

=Sheet1!10:10 if the active cell is in row 11

etc.

This definition (with an adjective used as a name) is made with an eye on generating readable formulas, e.g.

= prior [balance]

is the intersection of the row above the formula and the [balance] column (any two range references separated by a space will return the intersection).  Since the row prior intersects all of the columns of the table, one could also use

=(prior [date])

to give the date of the previous transactions.

 

If your workbook is sufficiently small that you can afford to use volatile functions, then you could, as an alternative, define 'prior' by the formula

=OFFSET(Table1[@],-1,0)

i.e. the table row above the current one.  Sample formulas might include the following

= IF( ISREF(prior Table1[#Headers]), "", [@Date] - (prior [Date]) )

for the interval between two transactions (could be of relevance if you are fortunate enough to accrue interest on current balances) or

= IF( ISREF(prior Table1[#Headers]), BFwd, [@Amount] + (prior [Balance]) )

for a running balance.  Here the first row will be characterised by the range 'prior' coinciding with the [#Headers] row so, instead of generating an error, the formula will reference the 'balance brought forward'.

 

Will your colleagues be able to read your formulas?  They will be able to deduce the intent but they would run a mile if you suggested they should take responsibility for the workbook!

@Peter Bartholomew 

need help.

we have inventory movement table for various stock items with stock  In and Out information.

I am try to create a pivot report, where we can new fields to table such as opening balance, running balance and closing balance for any given point in a time.

can someone help, how to write a formula for opening balance, running balance and closing balance.

see attached spreadsheet for example

@Sam_3026 

Unless @Wyn Hopkins wishes your question to be dealt with here, I suggest you open a new thread. 

I would also observe that since there are some of the most competent Excel practitioners worldwide responding to this thread it would be a mistake to narrow your potential solutions to a specific approach.

Hi @Sam_3026 ,

 

Yes if you could just post a new item to the community about this that would be great.

 

@   us in if you like

 

Cheers

 

Wyn

Related Conversations