2023년 초, Google은(Google introduced several new functions) 배열 작업을 위한 8가지 기능을 포함하여 Sheets에 몇 가지 새로운 기능을 도입했습니다. 이러한 함수를 사용하면 배열을 행이나 열로 변환하거나, 행이나 열에서 새 배열을 만들거나, 현재 배열을 추가할 수 있습니다.
배열 작업에 더 많은 유연성을 제공하고 기본 ARRAYFORMULA(ARRAYFORMULA) 함수 를 넘어서 Google 스프레드시트의 수식(formulas in Google Sheets) 과 함께 이러한 배열 함수를 사용하는 방법을 살펴보겠습니다 .
팁: Microsoft Excel을(Microsoft Excel) 사용하는 경우 이러한 기능 중 일부가 익숙해 보일 수 있습니다 .

배열 변환: TOROW 및 TOCOL
단일 행이나 열로 변환하려는 데이터세트에 배열이 있는 경우 TOROW 및 TOCOL 함수를 사용할 수 있습니다.
각 함수의 구문은 TOROW(TOROW) (배열, 무시, 스캔) 및 TOCOL (배열, 무시, 스캔) 과 동일하며 둘 다에 첫 번째 인수만 필요합니다.
- 배열: "A1:D4" 형식으로 변환하려는 배열입니다.
- 무시: 기본적으로 무시되는 매개 변수는 없습니다(0). 그러나 공백을 무시하려면 1을 사용하고, 오류를 무시하려면 2를 사용하고, 공백 및 오류를 무시하려면 3을 사용할 수 있습니다.
- Scan: 이 인수는 배열의 값을 읽는 방법을 결정합니다. 기본적으로 이 함수는 행별로 검색하거나 False(False) 값을 사용하여 검색 하지만 원하는 경우
True 를 사용하여 열별로 검색할 수 있습니다.(True)
TOROW 및 TOCOL 함수와 해당 공식을
사용하여 몇 가지 예를 살펴보겠습니다 .
이 첫 번째 예에서는 배열 A1부터 C3까지를 가져와서 다음 수식과 함께 기본 인수를 사용하여 행으로 변환합니다.
=TOROW(A1:C3)

보시다시피 배열은 이제 한 행에 있습니다. 기본 스캔 인수를 사용했기 때문에 함수는 왼쪽에서 오른쪽(A, D, G)으로 읽은 다음 아래로 읽은 다음 완료될 때까지 다시 왼쪽에서 오른쪽(B, E, H)으로 행별로 스캔합니다.

행 대신 열별로 배열을 읽으려면 스캔 인수에 True를 사용할 수 있습니다. (True)무시 인수를 비워 두겠습니다. 공식은 다음과 같습니다.
=TOROW(A1:C3,,TRUE)

이제 함수가 배열을 위에서 아래로(A, B, C), 위에서 아래로(D, E, F), 위에서 아래로(G, H, I) 읽는 것을 볼 수 있습니다.

TOCOL 함수는 동일한 방식 으로(TOCOL) 작동하지만 배열을 열로 변환합니다. A1부터 C3까지 동일한 범위를 사용하여 기본 인수를 사용하는 수식은 다음과 같습니다.
=목차(A1:C3)

다시 한번, scan 인수에 대한 기본값을 사용하여 함수는 왼쪽에서 오른쪽으로 읽고 결과를 제공합니다.

행 대신 열별로 배열을 읽으려면 다음과 같이 스캔 인수에
True를 삽입하십시오.(True)
=TOCOL(A1:C3,,TRUE)

이제 함수가 대신 위에서 아래로 배열을 읽는 것을 볼 수 있습니다.

행(New Array From Rows) 이나 열(Columns) 에서 새 배열 만들기 : CHOOSEROWS 및 CHOOSECOLS
기존 배열에서 새 배열을 생성할 수도 있습니다. 이를 통해 다른 셀 범위의 특정 값만 포함하는 새 셀 범위를 만들 수 있습니다. 이를 위해 CHOOSEROWS(CHOOSEROWS) 및 CHOOSECOLS Google 스프레드시트 기능을(Google Sheets functions) 사용합니다 .
각 함수의 구문은 CHOOSEROWS (array, row_num, row_num_opt) 및 CHOOSECOLS (array, col_num, col_num_opt)와 비슷합니다. 여기서 처음 두 인수는 둘 다에 필요합니다.
- 배열: "A1:D4" 형식의 기존 배열입니다.
- Row_num 또는 Col_num: 반환하려는 첫 번째 행 또는 열의 번호입니다.
- Row_num_opt 또는 Col_num_opt : 반환하려는 추가 행 또는 열의 번호입니다. Google에서는(Google) 아래에서 위로 행을 반환하거나 오른쪽에서 왼쪽으로 열을 반환하려면
음수를 사용할 것을(use negative numbers) 제안합니다 .
CHOOSEROWS 및 CHOOSECOLS 와 해당 공식을
사용하는 몇 가지 예를 살펴보겠습니다 .
이 첫 번째 예에서는 A1부터 B6까지의 배열을 사용합니다. 우리는 행 1, 2, 6의 값을 반환하려고 합니다. 수식은 다음과 같습니다.
=선택행(A1:B6,1,2,6)

보시다시피, 우리는 새 배열을 만들기 위해 이 세 개의 행을 받았습니다.

또 다른 예로 동일한 배열을 사용하겠습니다. 이번에는 1, 2, 6행을 반환하되 2, 6행은 역순으로 반환하려고 합니다. 양수 또는 음수를 사용하여 동일한 결과를 얻을 수 있습니다.
음수를 사용하면 다음 수식을 사용합니다.
=CHOOSEROWS(A1:B6,1,-1,-5)

설명하자면 1은 반환할 첫 번째 행이고, -1은 반환할 두 번째 행(맨 아래에서 시작하는 첫 번째 행), -5는 맨 아래에서 다섯 번째 행입니다.
양수를 사용하면 다음 공식을 사용하여 동일한 결과를 얻을 수 있습니다.
=선택행(A1:B6,1,6,2)
CHOOSECOLS 함수는 행 대신 열에서 새 배열을 만들 때 사용한다는 점을 제외하면 유사하게 작동합니다
.(CHOOSECOLS)
A1부터 D6까지의 배열을 사용하면 다음 수식으로 열 1(열 A)과 4(열 D)를 반환할 수 있습니다.
=CHOOSECOLS(A1:D6,1,4)

이제 우리는 두 개의 열만 포함하는 새로운 배열을 갖게 되었습니다.

또 다른 예로, 열 4부터 시작하는 동일한 배열을 사용합니다. 그런 다음 먼저 열 1과 2에 2(열 B)를 추가합니다. 양수 또는 음수를 사용할 수 있습니다.
=CHOOSECOLS(A1:D6,4,2,1)
=CHOOSECOLS(A1:D6,4,-3,-4)

위 스크린샷에서 볼 수 있듯이 수식 입력줄(Formula Bar) 이 아닌 셀에 수식이 있는 경우 두 옵션을 모두 사용해도 동일한 결과를 얻을 수 있습니다.
참고: Google 에서는 결과 배치를 반대로 하기 위해
음수를 사용할 것을 제안하므로 양수를 사용하여 올바른 결과를 받지 못하는 경우 이 점을 염두에 두십시오.(Google suggests using negative numbers)
(Wrap)새 배열을(New Array) 만들기 위한 래핑 : WRAPROWS 및 WRAPCOLS
기존 배열에서 새 배열을 만들고 각각의 특정 수의 값으로 열이나 행을 래핑하려는 경우 WRAPROWS 및(WRAPROWS) WRAPCOLS 함수(WRAPCOLS) 를 사용할 수 있습니다 .
각 함수의 구문은 WRAPROWS(WRAPROWS) (범위, 개수, 패드) 및 WRAPCOLS (범위, 개수, 패드)와 동일합니다 . 여기서 처음 두 인수는 둘 다에 필요합니다.
- 범위: 배열에 사용하려는 기존 셀 범위("A1:D4" 형식)입니다.
- 개수: 각 행 또는 열의 셀 수입니다.
- Pad: 이 인수를 사용하여 빈 셀에 텍스트나 단일 값을 배치할 수 있습니다. 이는 빈 셀에 대해 표시되는 #N/A 오류를 대체합니다. 텍스트나 값을 따옴표 안에 포함하세요.
WRAPROWS 및 WRAPCOLS 함수와 해당 공식을
사용하여 몇 가지 예를 살펴보겠습니다 .
이 첫 번째 예에서는 A1부터 E1까지의 셀 범위를 사용합니다. 각 행에 세 개의 값이 포함된 행을 래핑하는 새 배열을 만듭니다. 공식은 다음과 같습니다.
=WRAPROWS(A1:E1,3)

보시다시피 각 행에 세 개의 값이 있는 올바른 결과를 가진 새로운 배열이 있습니다. 배열에 빈 셀이 있으므로 #N/A 오류가 표시됩니다. 다음 예에서는 pad 인수를 사용하여 오류를 "None" 텍스트로 대체합니다. 공식은 다음과 같습니다.
=WRAPROWS(A1:E1,3,"없음")

이제 Google Sheets(Google Sheets) 오류 대신 단어를 볼 수 있습니다 .
WRAPCOLS 함수는 기존 셀 범위에서 새 배열을 생성하여 동일한 작업을 수행하지만 행 대신 열을 래핑하여 이를 수행합니다
.(WRAPCOLS)
여기서는 A1부터 E3까지 동일한 배열을 사용하여 각 열의 세 가지 값으로 열을 래핑합니다.
=랩콜(A1:E1,3)

WRAPROWS 예제 와 마찬가지로 올바른 결과를 받았지만 빈 셀로 인해 오류도 발생했습니다. 이 수식을 사용하면 pad 인수를 사용하여 "Empty"라는 단어를 추가할 수 있습니다.
=WRAPCOLS(A1:E1,3,"비어 있음")

이 새로운 배열은 오류 대신 단어를 사용하면 훨씬 더 좋아 보입니다.
결합하여 (Combine)새로운 어레이(New Array) 생성 : HSTACK 및 VSTACK
우리가 살펴볼 마지막 두 가지 함수는 배열을 추가하는 것입니다. HSTACK 및 VSTACK을(VSTACK) 사용하면 둘 이상의 셀 범위를 함께 추가하여 수평 또는 수직으로 단일 배열을 형성할 수 있습니다.
각 함수의 구문은 HSTACK (range1, range2,...) 및 VSTACK (range1, range2,...)과 동일하며 첫 번째 인수만 필요합니다. 그러나 첫 번째 범위와 다른 범위를 결합하는 두 번째 인수를 거의 항상 사용하게 됩니다.
- Range1: 배열에 사용하려는 첫 번째 셀 범위로, "A1:D4" 형식입니다.
- Range2 ,...: 배열을 만들기 위해 첫 번째 셀 범위에 추가하려는 두 번째 셀 범위입니다. 세 개 이상의 셀 범위를 결합할 수 있습니다.
HSTACK 및 VSTACK 과 해당 공식을
사용하는 몇 가지 예를 살펴보겠습니다 .
첫 번째 예에서는 다음 수식을 사용하여 A1~D2 범위와 A3~D4 범위를 결합합니다.
=HSTACK(A1:D2,A3:D4)

데이터 범위가 결합되어(data ranges combined) 단일 수평 배열을 형성하는 것을
볼 수 있습니다 .
VSTACK 기능 의 예를 들어 세 가지 범위를 결합합니다. 다음 수식을 사용하여 A2~C4, A6~C8, A10(A10) ~ C12 범위를 사용합니다 .
=VSTACK(A2:C4,A6:C8,A10:C12)

이제 단일 셀의 수식을 사용하여 모든 데이터가 포함된 하나의 배열이 생겼습니다.
쉽게 배열 조작
SUM 함수나 IF 함수 와 같은 특정 상황에서는 ARRAYFORMULA를(ARRAYFORMULA) 사용할 수 있지만 이러한 추가 Google Sheets 배열 수식을 사용하면 시간을 절약할 수 있습니다. 단일 배열 수식을 사용하여 원하는 대로 정확하게 시트를 정렬하는 데 도움이 됩니다.
배열이 아닌 함수를 포함하는 이와 같은 더 많은 튜토리얼을 보려면 Google 스프레드시트에서 (SUMIF function in Google Sheets)COUNTIF 또는 SUMIF 함수를 사용하는 방법을 살펴보세요 .
How to Use Array Formulas in Google Sheets
In early 2023, Google introduced several new functions for Sheets, including eight for working with arrays. Using these functions, you can transform an array into a row or column, create a new array from a row or column, or append a current array.
With more flexibility for working with arrays and going beyond the basic ARRAYFORMULA function, let’s look at how to use these array functions with formulas in Google Sheets.
Tip: Some of these functions may look familiar to you if you also use Microsoft Excel.

Transform an Array: TOROW and TOCOL
If you have an array in your dataset that you want to transform into a single row or column, you can use the TOROW and TOCOL functions.
The syntax for each function is the same, TOROW(array, ignore, scan) and TOCOL(array, ignore, scan) where only the first argument is required for both.
- Array: The array you want to transform, formatted as “A1:D4.”
- Ignore: By default, no parameters are ignored (0), but you can use 1 to ignore blanks, 2 to ignore errors, or 3 to ignore blanks and errors.
- Scan: This argument determines how to read the values in the array. By default, the function scans by row or using the value False, but you can use True to scan by column if you prefer.
Let’s walk through a few examples using the TOROW and TOCOL functions and their formulas.
In this first example, we’ll take our array A1 through C3 and turn it into a row using the default arguments with this formula:
=TOROW(A1:C3)

As you can see, the array is now in a row. Because we used the default scan argument, the function reads from left to right (A, D, G), down, then the left to right again (B, E, H) until complete—scanned by row.

To read the array by column instead of row, we can use True for the scan argument. We’ll leave the ignore argument blank. Here’s the formula:
=TOROW(A1:C3,,TRUE)

Now you see the function reads the array from top to bottom (A, B, C), top to bottom (D, E, F), and top to bottom (G, H, I).

The TOCOL function works the same way but transforms the array to a column. Using the same range, A1 through C3, here’s the formula using the default arguments:
=TOCOL(A1:C3)

Again, using the default for the scan argument, the function reads from left to right and provides the result as such.

To read the array by column instead of row, insert True for the scan argument like this:
=TOCOL(A1:C3,,TRUE)

Now you see the function reads the array from top to bottom instead.

Create a New Array From Rows or Columns: CHOOSEROWS and CHOOSECOLS
You may want to create a new array from an existing one. This lets you make a new cell range with only specific values from another. For this, you’ll use the CHOOSEROWS and CHOOSECOLS Google Sheets functions.
The syntax for each function is similar, CHOOSEROWS (array, row_num, row_num_opt) and CHOOSECOLS (array, col_num, col_num_opt), where the first two arguments are required for both.
- Array: The existing array, formatted as “A1:D4.”
- Row_num or Col_num: The number of the first row or column you want to return.
- Row_num_opt or Col_num_opt: The numbers for additional rows or columns you want to return. Google suggests you use negative numbers to return rows from the bottom up or columns from right to left.
Let’s look at a few examples using CHOOSEROWS and CHOOSECOLS and their formulas.
In this first example, we’ll use the array A1 through B6. We want to return the values in rows 1, 2, and 6. Here’s the formula:
=CHOOSEROWS(A1:B6,1,2,6)

As you can see, we received those three rows to create our new array.

For another example, we’ll use the same array. This time, we want to return rows 1, 2, and 6 but with 2 and 6 in reverse order. You can use positive or negative numbers to receive the same result.
Using negative numbers, you’d use this formula:
=CHOOSEROWS(A1:B6,1,-1,-5)

To explain, 1 is the first row to return, -1 is the second row to return which is the first row starting at the bottom, and -5 is the fifth row from the bottom.
Using positive numbers, you’d use this formula to obtain the same result:
=CHOOSEROWS(A1:B6,1,6,2)
The CHOOSECOLS function works similarly, except you use it when you want to create a new array from columns instead of rows.
Using the array A1 through D6, we can return columns 1 (column A) and 4 (column D) with this formula:
=CHOOSECOLS(A1:D6,1,4)

Now we have our new array with only those two columns.

As another example, we’ll use the same array starting with column 4. We’ll then add columns 1 and 2 with 2 (column B) first. You can use either positive or negative numbers:
=CHOOSECOLS(A1:D6,4,2,1)
=CHOOSECOLS(A1:D6,4,-3,-4)

As you can see in the above screenshot, with the formulas in the cells rather than the Formula Bar, we receive the same result using both options.
Note: Because Google suggests using negative numbers to reverse the placement of the results, keep this in mind if you aren’t receiving the correct results using positive numbers.
Wrap to Create a New Array: WRAPROWS and WRAPCOLS
If you want to create a new array from an existing one but wrap the columns or rows with a certain number of values in each, you can use the WRAPROWS and WRAPCOLS functions.
The syntax for each function is the same, WRAPROWS (range, count, pad) and WRAPCOLS (range, count, pad), where the first two arguments are required for both.
- Range: The existing cell range you want to use for an array, formatted as “A1:D4.”
- Count: The number of cells for each row or column.
- Pad: You can use this argument to place text or a single value in empty cells. This replaces the #N/A error you’ll receive for the blank cells. Include the text or value within quotation marks.
Let’s walk through a few examples using the WRAPROWS and WRAPCOLS functions and their formulas.
In this first example, we’ll use the cell range A1 through E1. We’ll create a new array wrapping rows with three values in each row. Here’s the formula:
=WRAPROWS(A1:E1,3)

As you can see, we have a new array with the correct result, three values in each row. Because we have an empty cell in the array, the #N/A error displays. For the next example, we’ll use the pad argument to replace the error with the text “None.” Here’s the formula:
=WRAPROWS(A1:E1,3,”None”)

Now, we can see a word instead of a Google Sheets error.
The WRAPCOLS function does the same thing by creating a new array from an existing cell range, but does so by wrapping columns instead of rows.
Here, we’ll use the same array, A1 through E3, wrapping columns with three values in each column:
=WRAPCOLS(A1:E1,3)

Like the WRAPROWS example, we receive the correct result but also an error because of the empty cell. With this formula, you can use the pad argument to add the word “Empty”:
=WRAPCOLS(A1:E1,3,”Empty”)

This new array looks much better with a word instead of the error.
Combine to Create a New Array: HSTACK and VSTACK
Two final functions we’ll look at are for appending arrays. With HSTACK and VSTACK, you can add two or more ranges of cells together to form a single array, either horizontally or vertically.
The syntax for each function is the same, HSTACK (range1, range2,…) and VSTACK (range1, range2,…), where only the first argument is required. However, you’ll almost always use the second argument, which combines another range with the first.
- Range1: The first cell range you want to use for the array, formatted as “A1:D4.”
- Range2,…: The second cell range you want to add to the first to create the array. You can combine more than two cell ranges.
Let’s look at some examples using HSTACK and VSTACK and their formulas.
In this first example, we’ll combine the ranges A1 through D2 with A3 through D4 using this formula:
=HSTACK(A1:D2,A3:D4)

You can see our data ranges combined to form a single horizontal array.
For an example of the VSTACK function, we combine three ranges. Using the following formula, we’ll use ranges A2 through C4, A6 through C8, and A10 through C12:
=VSTACK(A2:C4,A6:C8,A10:C12)

Now, we have one array with all of our data using a formula in a single cell.
Manipulate Arrays With Ease
While you can use ARRAYFORMULA in certain situations, like with the SUM function or IF function, these additional Google Sheets array formulas can save you time. They help you arrange your sheet exactly as you want it and with a single array formula.
For more tutorials like this, but with non-array functions, look at how to use the COUNTIF or SUMIF function in Google Sheets.