UNPIVOT

Unpivot data from wide to tall format

Formula definition
=ARRAYFORMULA(SPLIT(FLATTEN(dimension&"🔢"&column_headers&"🔢"&data_range),"🔢"))

Source: Ben Collins submitted by Keshia Rose

Function Details

This function unpivots data from a wide format to a tall format, making it easier to analyze and work with in databases, visualizations, or other applications. It takes a single column of data (dimension), column headers, and a range of data values, and returns a table with the dimension, column headers, and corresponding data values in separate rows. To use this function, define dimension as the column containing the dimension data (such as names or categories), column_headers as the column containing the pivoted headers (e.g., dates or subcategories), and data_range as the matrix containing the data to be unpivoted. Place this function in the first cell where you want the new unpivoted data to appear, and it will automatically reformat the specified range into an expanded format. This function produces an array of values outside of the cell containing this formula.

Function name: UNPIVOT

Function description: Unpivot data from wide to tall format

Argument placeholders: dimension, column_headers, data_range

Formula definition: =ARRAYFORMULA(SPLIT(FLATTEN(dimension&"🔢"&column_headers&"🔢"&data_range),"🔢"))

Argument description (dimension): The single column/dimension of data you want to unpivot. These values will be repeated.

Argument example (dimension): C21:C24

Argument description (column_headers): The column headers to be unpivoted into rows.

Argument example (column_headers): D20:G20

Argument description (data_range): The range of data values to be unpivoted.

Argument example (data_range): D21:G24

What is a Named Function in Google Sheets?

Named functions enable the creation of custom, reusable formulas that mimic built-in functions, streamlining calculations and data manipulations. These functions simplify complex formulas, making spreadsheets more readable and less prone to errors. By encapsulating intricate logic within a single function call, they enhance consistency across your data. Utilizing named functions reduces the need to write lengthy formulas repeatedly, thereby improving workflow efficiency and productivity in data analysis and management.

How to Add This Function to Google Sheets (Easy Download & Import)

Follow these simple steps to download and import the function into your spreadsheet. This method is the quickest and easiest way to add the named function to your Google Sheets document, but will not include the argument description and examples:

  1. Download the Formula: Click on the download button at the top of this page to download a file with the formula.
  2. Open Google Sheets: Open your Google Sheets document, from the top menu select Data > Named functions. Click Import function.
  3. Import the function: Select Upload and select the file you downloaded with the function. Click Import all or select which function(s) to import and click Import.

Once added, the function will be ready to use in your document like any other built-in function. Simply type the function name and provide the required inputs to use it in your calculations.

How to Add This Function to Google Sheets (Manual)

Follow these simple steps to integrate the function into your spreadsheet:

  1. Open Google Sheets: Open your Google Sheets document, from the top menu select Data > Named functions. Click Add new function.
  2. Copy the Formula: For each input copy and paste the information from above.
    • Copy the name of the function to the Function name input.
    • Copy the description of the function to the Function description input.
    • Copy each placeholder one at a time into the Argument placeholders input, if there are any placeholdes.
    • Copy the formula of the function to the Formula definition input.
    Click Next.
  3. Add additional details: Optionally you can add a description and example for the placeholders.
  4. Save the function: Click Create to add the function to your document.

Once added, the function will be ready to use in your document like any other built-in function. Simply type the function name and provide the required inputs to use it in your calculations.

Copyright © 2024 Keshia Rose. All rights reserved for website content. Individual functions are available under an MIT License.

This site is not associated with or endorsed by Google.