Write formulas with structured references
Excel tables9 minPremium
Builds on Add a total row and calculated columns to a table, Total by several conditions with SUMIFS and Count what matches with COUNTIF and COUNTIFS.
A sales analyst in Montreal sends a weekly summary built on a table of orders. She had totaled the Amount column as D2:D250, and every order after row 250 went missing from the report.
How it works
A structured reference names part of a table instead of its cells. It grows and shrinks with the table, so a total never stops at an old last row.
| Row | A | B |
|---|---|---|
| 1 | Reference | What it covers |
| 2 | Sales[Amount] | the data in the Amount column, without the heading or the total row |
| 3 | [@Amount] | the Amount in the formula's own row |
| 4 | Sales[[#Totals], | the Amount cell of the total row |
| 5 | Sales[#All] | the whole table, headings and total row included |
Outside the table, start with the table's name. Inside it, Excel leaves the name out: [Amount] is the column and [@Amount] the same row. You rarely type one in full. Type the table name and an opening bracket and Excel lists the columns, or select a column's cells while you write a formula and Excel writes the reference for you. Every function that takes a range takes one, so =SUMIFS( totals one region and reads almost as a sentence. Filled down, a column reference such as Sales[Region] stays as it is, so it needs no $ signs; filled to the right, it moves to the next column.
Example
The analyst's table is named Orders.
=SUM(Orders[Amount])- Step 1:
Sales[Amount]is the Amount data,C2:C7, without the heading or the total. - Step 2:
[@Amount]in a formula on row 4 means C4, the Amount of the same row. - Step 3:
Sales[#All]is everything, from the headings to the total row.
Sales[Amount] and Sales[#All] take in the new row by themselves.Common mistakes
=SUM(keeps adding the same cells when the table grows past row 250.D2:D250) =SUM(follows the table.Sales[Amount]) Sales[@Amount]in a row the table doesn't reach, such as under the total row, shows#VALUE!, because that row has no Amount. For the whole column, useSales[Amount].- A reference to the same row needs a second pair of brackets when the column name has a space:
[@[Unit price]]. - A formula that mixes a table column with a plain range, such as
=SUMIFS(, showsSales[Amount], B2:B250, G2) #VALUE!once the two stop being the same size. Use the table's columns throughout.
In short
Table[Column]is a column's data, and it grows with the table.[@Column]is the value in the formula's own row.- Outside the table, start with the table's name, as in
=SUM(.Sales[Amount]) - Use one table's columns throughout a formula, not a mix of columns and plain ranges.
Practice
Premium5 exercises: 3 table tasks, 1 formula and 1 quiz question.
Practice is part of Premium
Every lesson is free to read, and you can practice the free lessons without an account. This lesson's exercises are part of Premium, which you add to a free account.
Have one? Sign in