Aula 02 - 2.02 Further - Using Structured References With Excel Tables
Aula 02 - 2.02 Further - Using Structured References With Excel Tables
tables
Applies To: Excel 2016 Excel 2013 Excel 2010 Excel 2007 Excel 2016 for Mac More...
When you create an Excel table, Excel assigns a name to the table, and to each column
header in the table. When you add formulas to an Excel table, those names can appear
automatically as you enter the formula and select the cell references in the table instead
of manually entering them. Here's an example of what Excel does:
Instead of using explicit cell references Excel uses table and column names
=Sum(C2:C7) =SUM(DeptSales[Sales Amount])
That combination of table and column names is called a structured reference. The names
in structured references adjust whenever you add or remove data from the table.
Structured references also appear when you create a formula outside of an Excel table
that references table data. The references can make it easier to locate tables in a large
workbook.
To include structured references in your formula, click the table cells you want to
reference instead of typing their cell reference in the formula. Let’s use the following
example data to enter a formula that automatically uses structured references to
calculate the amount of a sales commission.
1. Copy the sample data in the table above, including the column headings, and
paste it into cell A1 of a new Excel worksheet.
2. To create the table, select any cell within the data range, and press Ctrl+T.
3. Make sure the My table has headers box is checked, and click OK.
4. In cell E2, type an equal sign (=), and click cell C2.
In the formula bar, the structured reference [@[Sales Amount]] appears after
the equal sign.
5. Type an asterisk (*) directly after the closing bracket, and click cell D2.
In the formula bar, the structured reference [@[% Commission]] appears after
the asterisk.
6. Press Enter.
Excel automatically creates a calculated column and copies the formula down
the entire column for you, adjusting it for each row.
Notice that while Excel copies your formula down the column, it doesn't use structured
references. If, for example, you add a column between the existing columns C and D,
you'd have to revise your formula.
1. Select any cell in the table to show the Table Tools > Design tab on the ribbon.
2. Type the name you want in the Table Name box, and press Enter.
Use valid characters Always start a name with a letter, an underscore character
(_), or a backslash (\). Use letters, numbers, periods, and underscore characters
for the rest of the name. You can’t use "C", "c", "R", or "r" for the name,
because they’re already designated as a shortcut for selecting the column or row
for the active cell when you enter them in the Name or Go To box.
Don’t use cell references Names can’t be the same as a cell reference, such as
Z$100 or R1C1.
Don’t use a space to separate words Spaces can’t be used in the name. You
can use the underscore character (_) and period (.) as word separators. For
example, DeptSales, Sales_Tax or First.Quarter.
Use no more than 255 characters A table name can have up to 255 characters.
Use unique table names Duplicate names aren’t allowed. Excel doesn’t
distinguish between upper and lowercase characters in names so if you enter
“Sales” but already have another name called “SALES" in the same workbook,
you’ll be prompted to choose a unique name.
Use an object identifier If you plan on having a mix of tables, PivotTables and
charts, it's a good idea to prefix your names with the object type. For example:
tbl_Sales for a sales table, pt_Sales for a sales PivotTable, and chrt_Sales for a
sales chart, or ptchrt_Sales for a sales PivotChart. This keeps all of your names
in an ordered list in the Name Manager.
=SUM(DeptSales[[#Totals],[Sales Amount]],DeptSales[[#Data],[Commission
Amount]])
Use brackets around specifiers All table, column, and special item specifiers
need to be enclosed in matching brackets ([ ]). A specifier that contains other
specifiers requires outer matching brackets to enclose the inner matching
brackets of the other specifiers. For example: =DeptSales[[Sales Person]:
[Region]]
All column headers are text strings But they don’t require quotes when
they’re used in a structured reference. Numbers or dates, such as 2014 or
1/1/2014, are also considered text strings. You can’t use expressions with
column headers. For example, the expression DeptSalesFYSummary[[2014]:
[2012]] won’t work.
Use brackets around column headers with special characters If there are special
characters, the entire column header needs to be enclosed in brackets, which means that
double brackets are required in a column specifier. For example:
=DeptSalesFYSummary[[Total $ Amount]]
Here’s the list of special characters that need extra brackets in the formula:
Tab
Line feed
Carriage return
Comma (,)
Colon (:)
Period (.)
Left bracket ([)
Right bracket (])
Pound sign (#)
Single quotation mark (')
Double quotation mark (")
Left brace ({)
Right brace (})
Dollar sign ($)
Caret (^)
Ampersand (&)
Asterisk (*)
Plus sign (+)
Equal sign (=)
Minus sign (-)
Greater than symbol (>)
Less than symbol (<)
Division sign (/)
Here’s the list of special characters that need an escape character (‘) in the
formula:
Which is
This structured reference: Refers to: By using the: cell
range:
All of the cells in
: (colon) range
=DeptSales[[Sales Person]:[Region]] two or more A2:B7
operator
adjacent columns
A combination of
=DeptSales[Sales , (comma) C2:C7,
two or more
Amount],DeptSales[Commission Amount] union operator E2:E7
columns
=DeptSales[[Sales Person]:[Sales The intersection of (space)
Amount]] DeptSales[[Region]:[% two or more intersection B2:C7
Commission]] columns operator
This special
item Refers to:
specifier:
#All The entire table, including column headers, data, and totals (if any).
#Data Just the data rows.
#Headers Just the header row.
#Totals Just the total row. If none exists, then it returns null.
Just the cells in the same row as the formula. These specifiers can’t be
#This Row
combined with any other special item specifiers. Use them to force
implicit intersection behavior for the reference or to override implicit
or
intersection behavior and refer to single values from a column.
@
Excel automatically changes #This Row specifiers to the shorter @
specifier in tables that have more than one row of data. But if your table
or
has only one row, Excel doesn’t replace the #This Row specifier, which
may cause unexpected calculation results when you add more rows. To
@[Column
avoid calculation problems, make sure you enter multiple rows in your
Name]
table before you enter any structured reference formulas.
The general rule to follow is this: If you’re using structured references within a table,
such as when you create a calculated column, you can use an unqualified structured
reference, but if you use the structured reference outside of the table, you need to use a
fully qualified structured reference.
Which
This structured reference: Refers to: is cell
range:
All the cells in the Sales
=DeptSales[[#All],[Sales Amount]] C1:C8
Amount column.
The header of the %
=DeptSales[[#Headers],[% Commission]] D1
Commission column.
The total of the Region
=DeptSales[[#Totals],[Region]] column. If there is no Totals B8
row, then it returns null.
=DeptSales[[#All],[Sales Amount]:[% All the cells in Sales Amount
C1:D8
Commission]] and % Commission.
Just the data of the %
=DeptSales[[#Data],[% Commission]:
Commission and Commission D2:E7
[Commission Amount]]
Amount columns.
Just the headers of the
=DeptSales[[#Headers],[Region]:[Commission
columns between Region and B1:E1
Amount]]
Commission Amount.
The totals of the Sales
Amount through Commission
=DeptSales[[#Totals],[Sales Amount]:
Amount columns. If there is C8:E8
[Commission Amount]]
no Totals row, then it returns
null.
=DeptSales[[#Headers],[#Data],[% Just the header and the data
D1:D7
Commission]] of % Commission.
=DeptSales[[#This Row], [Commission The cell at the intersection of E5 (if
Amount]] the current row and the the
Commission Amount current
or column. If used in the same row is 5)
row as a header or total row,
Which
This structured reference: Refers to: is cell
range:
this will return a #VALUE!
error.
And while
If the fill
filling, you Then:
direction is:
press:
Up or down Nothing There is no column specifier adjustment.
Up or down Ctrl Column specifiers adjust like a series.
Right or left None Column specifiers adjust like a series.
Instead of overwriting values in current cells, current
Up, down,
Shift cell values are moved and column specifiers are
right, or left
inserted.
Related Topics
Overview of Excel tables
Video: Create and format an Excel table
Total the data in an Excel table
Format an Excel table
Resize a table by adding or removing rows and columns
Filter data in a range or table
Convert a table to a range
Excel table compatibility issues
Export an Excel table to SharePoint
Overviews of formulas in Excel