BYCOL Differences: Sheets vs. Excel

The BYCOL function varies slightly between Google Sheets and Excel but remains true to its core purpose. It applies a lambda to each column in an array, which is why it’s also referred to as a lambda helper function.

In Google Sheets, BYCOL can return two-dimensional arrays, unlike in Excel.

We can utilize the ARRAYFORMULA function with the BYCOL function in Google Sheets to obtain a two-dimensional array.

This feature proves useful in situations where you need to extract the largest or smallest two values in each column simultaneously.

The primary objective of the BYCOL function in both Excel and Google Sheets is to apply a lambda function for a column to each column in a range, separated by columns.

Consequently, the output will be a row of values equivalent to the number of columns in the source array.

The key difference between BYCOL in Excel and Google Sheets is that in the latter, the function can sometimes return multiple rows. We’ll explore this with two examples shortly.

Now, let’s delve into how they operate similarly in both Excel and Google Sheets.

Note: BYCOL utilizes LAMBDA functions, a feature available in Microsoft 365 and Excel for the Web. This allows for BYCOL-like functionality in these versions of Excel.

Finding Common Ground: BYCOL in Google Sheets & Excel

Let’s simplify by using a 4 x 3 matrix in both Excel and Google Sheets, placed in the range A1:C4:

5105
4206
6305
244

To total each column and return the individual results in cells A5:C5, we can utilize the following BYCOL formula, which works in both Excel and Google Sheets:

=BYCOL(A1:C4, LAMBDA(col, SUM(col)))

If you need a quick explanation:

=SUM(A1:C4) // sums the range A1:C4.

We’ll convert this to a lambda function:

=LAMBDA(col, SUM(col))(A1:A4)

We’ll apply this lambda function to the array A1:C4 instead of A1:A4. BYCOL does precisely that.

The above formula remains similar in Google Sheets and Excel. However, the key difference is an additional capability in Google Sheets.

How BYCOL Differs in Excel and Google Sheets

Here are two examples that illustrate the key difference between BYCOL in Google Sheets and Excel.

Example #1: Using LARGE Function

Let’s consider the following sample data in cells A1:F4 in both Google Sheets and Excel:

Athlete 1Athlete 2Athlete 3Athlete 4Athlete 5
Attempt 16.87.16.87.26.4
Attempt 27.17.276.96.7
Attempt 37.276.97.56.9

This data represents the distances achieved by 5 athletes in a long jump event across three attempts.

To find the longest distance of each athlete across their attempts, we can use the following BYCOL formula in cell B5 in both Excel and Sheets:

=BYCOL(B2:F4, LAMBDA(score, MAX(score)))

Output:

7.27.277.56.9

BYCOL can handle complex array operations, but finding the top two scores for each athlete requires a different approach.

In Google Sheets, we can utilize the following formula that takes advantage of its unique functionalities:

=BYCOL(B2:F4, LAMBDA(score, ARRAYFORMULA(LARGE(score, VSTACK(1, 2)))))

Output:

7.27.277.56.9
7.17.16.97.26.7

However, this formula won’t work in Excel, as Excel’s BYCOL doesn’t support functions like ARRAYFORMULA, which can return multi-row outputs.

If you attempt it, Excel will return a #CALC error, stating ‘Nested arrays are not supported.’

The main difference between BYCOL in Excel and Google Sheets is that Excel cannot handle multi-row outputs.

Example #2: Using SEQUENCE Function

Let’s say you have the numbers 5, 4, and 2 in cells A1:C1.

In Google Sheets, you can use the following BYCOL formula in cell A2 to generate a sequence taking values from the array:

=BYCOL(A1:C1, LAMBDA(col, SEQUENCE(col)))

Output:

111
222
33
44
5

However, this won’t work in Excel.

In summary, BYCOL in Google Sheets can return two-dimensional array output, whereas in Excel, it cannot.

Resources

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Highlight Upcoming Birthdays in Google Sheets

When highlighting upcoming birthdays in Google Sheets, one important aspect is ignoring the year...

Compare Two Tables for Differences in Excel

To compare two tables with similar data for differences, you can use the XLOOKUP...

Calculate Weighted Average in Pivot Table in Google Sheets

You can calculate a weighted average in a Pivot Table using a custom formula...

Summarize Data and Keep the Last Record in Google Sheets

In Google Sheets, we can summarize data (like sum, average, min, max, count) using...

More like this

Lookup Previous Values Dynamically in Excel and Google Sheets

Sometimes, you may want to look up the previous values relative to the current...

Sort Data but Keep Blank Rows in Excel and Google Sheets

Using a dynamic array formula or the FILTER command, we can sort data and...

Lookup Values Under Categories in Excel and Google Sheets

We can use a combination of XLOOKUP and VLOOKUP in both Excel and Google...

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.