Resources

A better way of calculating running totals

Running totals are commonly used for keeping track of sales figures and monitoring the balance on a bank statement.

But how can you create one in Excel?

There are multiple methods, but let's look at two contrasting ones (as shown in the video).

@globalexcelsummit Running totals are commonly used for keeping track of sales figures and monitoring the balance on a bank statement. But how can you create one in Excel? There are multiple methods, but let's look at two contrasting ones (as shown in the video). A table called tblSales houses some sales data, and we want to return the running total of the Total (ยฃ) column. ๐—ง๐—ฟ๐—ฎ๐—ฑ๐—ถ๐˜๐—ถ๐—ผ๐—ป๐—ฎ๐—น ๐— ๐—ฒ๐˜๐—ต๐—ผ๐—ฑ =๐š‚๐š„๐™ผ($๐™ฑ$๐Ÿน:๐™ฑ๐Ÿน) The first cell in the Total (ยฃ) column is referenced inside SUM as part of an expanding range. The left part is made absolute to prevent it from shifting as the formula is copied down using the fill handle. On the other side of the colon, the ending reference is relative to ensure the row number increases incrementally. ๐— ๐—ผ๐—ฑ๐—ฒ๐—ฟ๐—ป ๐— ๐—ฒ๐˜๐—ต๐—ผ๐—ฑ =๐š‚๐™ฒ๐™ฐ๐™ฝ(0,๐š๐š‹๐š•๐š‚๐šŠ๐š•๐šŽ๐šœ[๐šƒ๐š˜๐š๐šŠ๐š• (ยฃ)], ๐™ป๐™ฐ๐™ผ๐™ฑ๐™ณ๐™ฐ(๐šŠ,๐š‹,๐šŠ+๐š‹)) SCAN applies a custom LAMBDA to each value in an array and returns another containing the intermediate values created after scanning. 0 is the ๐š’๐š—๐š’๐š๐š’๐šŠ๐š•_๐šŸ๐šŠ๐š•๐šž๐šŽ, whilst the Total (ยฃ) column is the ๐šŠ๐š›๐š›๐šŠ๐šข. The LAMBDA takes two parameters: accumulator (๐šŠ) and value (๐š‹). ๐šŠ starts at the ๐š’๐š—๐š’๐š๐š’๐šŠ๐š•_๐šŸ๐šŠ๐š•๐šž๐šŽ and iteratively totals up the figures, whilst ๐š‹ contains the current one that gets added to ๐šŠ. ๐—ฅ๐—ฒ๐—บ๐—ฎ๐—ฟ๐—ธ๐˜€ The obvious upside of the newer method is only a single formula is required, whereas 10 are needed for the old approach. Using fewer formulas is more efficient โ€” there's less to go wrong. However, the downside is dynamic array formulas are incompatible with tables, meaning they can only live outside. There are other table-compatible methods that use structured references, but they still require one formula per value. Will spilled formulas become compatible with tables in the future? Watch this space. #exceleration #excel #globalexcelsummit โ™ฌ original sound - globalexcelsummit

A table called tblSales houses some sales data, and we want to return the running total of the Total (ยฃ) column.

Traditional Method

=๐š‚๐š„๐™ผ($๐™ฑ$๐Ÿน:๐™ฑ๐Ÿน)

The first cell in the Total (ยฃ) column is referenced inside SUM as part of an expanding range.

The left part is made absolute to prevent it from shifting as the formula is copied down using the fill handle.

On the other side of the colon, the ending reference is relative to ensure the row number increases incrementally.

Modern Method

=๐š‚๐™ฒ๐™ฐ๐™ฝ(0,๐š๐š‹๐š•๐š‚๐šŠ๐š•๐šŽ๐šœ[๐šƒ๐š˜๐š๐šŠ๐š• (ยฃ)],
๐™ป๐™ฐ๐™ผ๐™ฑ๐™ณ๐™ฐ(๐šŠ,๐š‹,๐šŠ+๐š‹))

SCAN applies a custom LAMBDA to each value in an array and returns another containing the intermediate values created after scanning.

0 is the ๐š’๐š—๐š’๐š๐š’๐šŠ๐š•_๐šŸ๐šŠ๐š•๐šž๐šŽ, whilst the Total (ยฃ) column is the ๐šŠ๐š›๐š›๐šŠ๐šข. The LAMBDA takes two parameters: accumulator (๐šŠ) and value (๐š‹).

๐šŠ starts at the ๐š’๐š—๐š’๐š๐š’๐šŠ๐š•_๐šŸ๐šŠ๐š•๐šž๐šŽ and iteratively totals up the figures, whilst ๐š‹ contains the current one that gets added to ๐šŠ.

Remarks

The obvious upside of the newer method is only a single formula is required, whereas 10 are needed for the old approach.

Using fewer formulas is more efficient โ€” there's less to go wrong.

However, the downside is dynamic array formulas are incompatible with tables, meaning they can only live outside.

There are other table-compatible methods that use structured references, but they still require one formula per value.

Will spilled formulas become compatible with tables in the future?

Watch this space.

For more Excel tips and tricks like this, check out our Video Tutorials page.

Andrew Moss
About the Author

Andrew Moss

Andrew is a technical writer who specialises in Microsoft Excel and data analysis. He has published hundreds of articles and social media posts aimed at helping people enhance their skills and spreading good practices.

Conversation

0 Comments

As you comment, let's keep the discussion friendly and respectful to add value to the conversation.

Thank you! Your comment has been sent!
Oops! Something went wrong while submitting the form.
Commenter profile pic.
Author Name
Comment Time

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere. uis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.

Reply
Delete
Commenter profile pic.
Author Name
Comment Time

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere. uis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.

Reply
Delete

Get Tickets

Benefit from an award-winning 3-day conference plus access to exclusive networking and additional Masterclass events.

Get Tickets
Close Cookie Popup
Cookie Preferences
By clicking โ€œAccept Allโ€, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage and assist in our marketing efforts as outlined in our privacy policy.
Strictly Necessary (Always Active)
Cookies required to enable basic website functionality.
Cookies helping us understand how this website performs, how visitors interact with the site, and whether there may be technical issues.
Cookies used to deliver advertising that is more relevant to you and your interests.
Cookies allowing the website to remember choices you make (such as your user name, language, or the region you are in).