3-D Referencing Structured Data Tables in Google Sheets

Published on

When you have several tables within a single sheet—not across multiple sheets in a workbook—you can use 3-D references to stack the data. If the tables are arranged vertically, the stacking will occur vertically; similarly, if they are arranged horizontally, the stacking will occur horizontally.

It’s important to note that 3-D referencing is unnecessary when you only have one or two tables.

The Use of 3-D Referencing for Structured Data Tables in Sheets

Assume you have sales data for January in one table, February in another, and so on, totaling 12 tables from January to December.

You can stack these tables by using just the first and last table references. This approach simplifies data manipulation, enabling you to easily calculate total sales or category-wise totals.

When using 3-D references in structured data tables, you should pay attention to a few important factors to maintain data integrity.

Field Labels:

The stacked data will include field labels between the tables. You might want to filter these out when using functions like QUERY; otherwise, their presence may cause mixed data type issues.

For example, if your tables contain a numeric field and a label appears in that column, stacking can lead to that column having mixed data types.

To filter out these labels, ensure that you use the same field label across all tables. This way, you can match the field label and filter out all such rows.

Data Types:

Maintaining consistent data types is another critical aspect of data integrity. Each table can have a different number of columns and rows, but the data types should remain uniform. For instance, if the first column contains text and the second column contains numeric values, this pattern should be consistent across all tables. If there are discrepancies, 3-D referencing may still function, but you might encounter issues with data manipulation due to mixed data types.

Dimension:

In vertical 3-D referencing of data tables, the maximum number of columns will be determined by the larger of the first or last table.

In horizontal 3-D referencing, the number of rows is determined by the larger of the first or last table.

Vertical 3-D Referencing of Structured Data Tables

In the following example, I have three tables named Jan, Feb, and Mar, arranged one below the other.

Structured tables arranged vertically in Google Sheets

You can use the following formula to create a 3-D reference to the entire tables:

=Jan[#ALL]:Mar
Example of vertical 3-D referencing in structured tables

To remove the header rows (field labels) and empty rows, use the following FILTER formula:

=LET(data, Jan[#ALL]:Mar, FILTER(data, CHOOSECOLS(data, 1)<>"Product ID", CHOOSECOLS(data, 1)<>""))

This formula filters out blank rows and rows containing the label “Product ID” in the first column, allowing you to manipulate the remaining data using QUERY or other functions.

Filtering out header rows in stacked structured tables

What if you want to perform a vertical 3-D reference of a specific column?

To reference the ‘Sales Amount’ field in all tables, use:

=Jan[Sales Amount]:Mar[Sales Amount]

You can apply the same FILTER by replacing “Product ID” with “Sales Amount” to filter out the labels:

=LET(data, Jan[Sales Amount]:Mar[Sales Amount], FILTER(data, CHOOSECOLS(data, 1)<>"Sales Amount", CHOOSECOLS(data, 1)<>""))
Vertical 3-D referencing of structured tables with one column

Horizontal 3-D Referencing of Structured Data Tables

Horizontal 3-D referencing is less common, but it can still be useful in certain scenarios.

Here, I have three tables named North, South, and West arranged horizontally.

Structured tables arranged horizontally in Google Sheets

To reference them, use:

=North[#ALL]:West

In this case, you don’t need to filter out field labels. Instead, the following formula will filter out any empty columns:

=LET(data, North[#ALL]:West, FILTER(data, CHOOSEROWS(data, 1)<>""))
Example of horizontal 3-D referencing in structured tables

Important Note

Google Sheets does not natively support 3-D referencing for regular data. If you need this functionality, you can use my custom Named function. For more information, check out this tutorial: 3-D Reference in Google Sheets (Workaround).

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.