Skip to content
Free Excel Tutorials
  • Home
  • Excel For Beginners
  • Excel Intermediate
  • Advanced Excel For Experts

Data Analysis

  • Example of COUNTIFS with variable table column in Excel
  • Excel Frequency Function Example
  • How To Insert and Customize Sparklines in Excel
  • Randomize/ Shuffle List in Excel
  • How To Create Pareto Chart in Excel

References

  • How to calculate two-way lookup VLOOKUP in Excel Table
  • Complete List of Excel Lookup and Reference Functions, References and Examples
  • Extract all partial matches in Excel
  • How to use Excel MMULT Function
  • Basic INDEX MATCH approximate in Excel

Data Validations

  • Excel Data validation date in specific year
  • Excel Data validation require unique number
  • Excel Data validation unique values only
  • Excel Data validation exists in list
  • Excel Data validation whole percentage only

Sum through n months in Excel

by

This tutorial shows how to Sum through n months in Excel using the example below;

Formula

=SUM(OFFSET(start,0,0,N,1))

Explanation

To sum a set of monthly data through n number of months, you can use a formula based on the SUM and OFFSET functions. In the example shown, the formula in G6 is:

=SUM(OFFSET(C5,0,0,G5,1))

How this formula works

In the example shown, we have monthly data for the years 2017 and 2018. The goal is to dynamically sum values through a given number of months, hardcoded as 6 in cell G5. This is done by feeding a reference constructed with the OFFSET function into the sum function.

Worked Example:   How to create dynamic named range with OFFSET in Excel

The OFFSET function let’s you build a reference using a starting point, a row and column offset, and a height and width. OFFSET is handy in formulas that dynamically average or sum “last n values”, “first n values”, and so on. In cell G6, OFFSET is configured like this:

OFFSET(C5,0,0,G5,1)

Translated: from a starting position of C5, build a reference 6 rows x 1 column with no offset. With the number 6 in G5, OFFSET returns the reference C5:C10 to SUM:

=OFFSET(C5,0,0,G5,1) // returns C5:C10
=SUM(C5:C10)) // returns 5775

The formula in G7 is set up the same way. The only difference is the starting point:

=OFFSET(D5,0,0,G5,1) // returns D5:D10
=SUM(D5:D10)) // returns 6380

When the number in G5 is changed, both formulas dynamically update and return a new result.

Worked Example:   Sum every n rows in Excel

Year to date variation

Instead of hardcoding a value into the formula, you can use the COUNT function to count existing entries in a given column and return that count to OFFSET. A generic version of this formula would look like this:

=SUM(OFFSET(start,0,0,COUNT(range),1))

where range references YTD values.

Worked Example:   Average last 5 values in columns in Excel

Post navigation

Previous Post:

44 Practical Excel IF function Examples

Next Post:

Large with criteria in Excel

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Learn Basic Excel

Ribbon
Workbook
Worksheets
Format Cells
Find & Select
Sort & Filter
Templates
Print
Share
Protect
Keyboard Shortcuts

Categories

  • Charts
  • Data Analysis
  • Data Validation
  • Excel Functions
    • Cube Functions
    • Database Functions
    • Date and Time Functions
    • Engineering Functions
    • Financial Functions
    • Information Functions
    • Logical Functions
    • Lookup and Reference Functions
    • Math and Trig Functions
    • Statistical Functions
    • Text Functions
    • Web Functions
  • Excel VBA
  • Excel Video Tutorials
  • Formatting
  • Grouping
  • Others

Logical Functions

  • IFERROR function: Description, Usage, Syntax, Examples and Explanation
  • IF function: Description, Usage, Syntax, Examples and Explanation
  • How to use Excel AND Function
  • Excel If, Nested If, And/Or Criteria Examples
  • Invoice status with nested if in Excel

Date Time

  • DAY function: Description, Usage, Syntax, Examples and Explanation
  • How to calculate nth day of year in Excel
  • Custom weekday abbreviation in Excel
  • Get last working day in month in Excel
  • Calculate time difference in hours as decimal value in Excel

Grouping

  • Map inputs to arbitrary values in Excel
  • Categorize text with keywords in Excel
  • Group times into unequal buckets in Excel
  • Calculate conditional mode with criteria in Excel
  • How to randomly assign data to groups in Excel

General

  • How to choose page/paper size in Excel before Printing
  • How to generate random number between two numbers in Excel
  • Using Existing Templates in Excel
  • Convert column number to letter in Excel
  • How to calculate percent of goal in Excel
© 2023 xlsoffice . All Right Reserved. | Teal Smiles | Abbreviations And Their Meaning