How to Sum Alternate Columns in Google Sheets

Published on

You may need to sum every alternate column in Google Sheets when you have other numeric data in the columns in between. For this, you can use different formula options, and here are some dynamic ones.

You can use the following formula to sum every alternate column in a row in Google Sheets:

=SUM(FILTER(row, MOD(SEQUENCE(1, COLUMNS(row)), 2)=1))

In this formula, replace ‘row’ with the row reference you want.

If you want to repeat the calculation for every row, you can use another formula:

=ARRAYFORMULA(MMULT(IF(MOD(SEQUENCE(1, COLUMNS(range)), 2)=1, N(range), 0), TOCOL(COLUMN(range)^0)))

In this formula, replace ‘range’ with the range you want to apply the formula to.

Let’s look at two examples applying these formulas.

Example of Summing Every Alternate Cell in a Row in Google Sheets

In the following example, I have the gross and net salaries of a few employees, where the data range is A1:I6, with the header rows in A1:I2. The first column contains the employee names. The gross salaries for quarters Q1 to Q4 are in the ranges B3:B6, D3:D6, F3:F6, and H3:H6.

To sum the gross salaries in the first row, you can use the following formula in cell J3:

=SUM(FILTER(B3:I3, MOD(SEQUENCE(1, COLUMNS(B3:I3)), 2)=1))
Example of summing every alternate column in a row in Google Sheets

Drag this down to apply it to every row in the range.

If you want to sum the net salaries in every alternate column, use this formula instead:

=SUM(FILTER(B3:I3, MOD(SEQUENCE(1, COLUMNS(B3:I3)), 2)=0))

Here, the FILTER function filters the cells in B3:I3 wherever the condition is TRUE. In the first formula, the condition is:

MOD(SEQUENCE(1, COLUMNS(B3:I3)), 2)=1

The MOD function returns 1 for every alternate cell starting from B3. The values in between will be 0.

In the first formula, the condition evaluates to TRUE wherever the MOD function returns 1. In the second formula, the condition evaluates to TRUE where the MOD function returns 0.

Example of Summing Every Alternate Column in a Range in Google Sheets

In the previous example, we dragged the formula down the row to apply it to all rows. Instead, you can convert it into an array formula using the BYROW function as follows:

=BYROW(B3:I6, LAMBDA(row, SUM(FILTER(row, MOD(SEQUENCE(1, COLUMNS(row)), 2)=1))))

In this case, we converted the earlier formula into a custom LAMBDA function:

LAMBDA(row, SUM(FILTER(row, MOD(SEQUENCE(1, COLUMNS(row)), 2)=1)))

We then used this within the BYROW lambda helper function to apply it to each row in the specified range.

Note: Replace =1 with =0 depending on whether you want to sum every alternate column starting from the first column or from the second column in the range.

Alternatively, you can use the following formula:

=ARRAYFORMULA(MMULT(IF(MOD(SEQUENCE(1, COLUMNS(B3:I6)), 2)=1, N(B3:I6), 0), TOCOL(COLUMN(B3:I6)^0)))

This sums the gross salary columns. To sum the net salary columns, replace =1 with =0:

Here, we also use the MOD function to return 1 for every alternate column starting from the first column, and 0 for the columns in between.

The IF function evaluates whether the MOD function returns 1. If TRUE, it returns the numeric values from that column; otherwise, it returns 0.

We used this as Matrix 1 in the MMULT function, where Matrix 2 is a column with the number 1, matching the number of columns in the range. This will return column-wise sums in Google Sheets.

Resources

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Expert Prashanth KV is a Diamond Product Expert in Google Sheets, officially recognized by Google for his contributions to the Docs Editors Help Community and featured in the Google Product Experts Directory. Explore his blog to learn advanced formulas, automation tips, and problem-solving techniques to elevate your spreadsheet skills.

Calculate Trip Days by Month (Start, End, and Full Days) in Google Sheets

If you're managing business travel in Google Sheets, you may need to calculate how...

Mode of Comma-Separated Numbers in Excel (Dynamic Array)

There is no dedicated function in Excel to directly find the mode of comma-separated...

How to Find Mode of Comma-Separated Numbers in Google Sheets

Working with comma-separated numbers inside a single cell is a common scenario in Google...

How to Count Merged Cells in Google Sheets (and Get Their Size)

Sometimes, you may have blocks of merged cells in a column or row. But...

More like this

Calculate Trip Days by Month (Start, End, and Full Days) in Google Sheets

If you're managing business travel in Google Sheets, you may need to calculate how...

How to Find Mode of Comma-Separated Numbers in Google Sheets

Working with comma-separated numbers inside a single cell is a common scenario in Google...

How to Count Merged Cells in Google Sheets (and Get Their Size)

Sometimes, you may have blocks of merged cells in a column or row. But...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.