Selection: Expand & Fill
This page details the usage of the .expand()
and .fill()
selection methods.
These methods are used to dynamically create selections for the purposes of extracting data sources that are routinely updated.
Source Data
The data source we’re using for these examples is shown below:
The full data source can be downloaded here. We’ll be using th 8th tab named “Table 3a”.
Table 3a
| A | B | C | D | E | F | G | H |
4 | Percentage change period on period | | | | | | | |
5 | Time period | Public new housing | Private new housing | Total new housing | Infrastructure new work | Public other new work | Private industrial new work | Private commercial new work |
6 | Annual dataset identifier code | MV5H | MV5I | MVM3 | MV5J | MV5K | MV5L | MV5M |
7 | Quarterly dataset identifier code | MV54 | MV55 | MVM7 | MV56 | MV57 | MV58 | MV59 |
8 | Monthly dataset identifier code | MV4O | MV4P | MVM2 | MV4Q | MV4R | MV4S | MV4T |
9 | 1998 | -19 | 1 | -1.2 | -2.8 | 5.4 | 1.9 | 8.4 |
10 | 1999 | -13.3 | -10 | -10.3 | -2.8 | 12.6 | 3.2 | 12 |
Expand
The expand method is roughly analogous to the act of selecting a cell in a speadsheet and dragging to increase that selection in a specific direction.
For example:
Table 3a
| A | B | C | D | E | F | G | H |
4 | Percentage change period on period | | | | | | | |
5 | Time period | Public new housing | Private new housing | Total new housing | Infrastructure new work | Public other new work | Private industrial new work | Private commercial new work |
6 | Annual dataset identifier code | MV5H | MV5I | MVM3 | MV5J | MV5K | MV5L | MV5M |
7 | Quarterly dataset identifier code | MV54 | MV55 | MVM7 | MV56 | MV57 | MV58 | MV59 |
8 | Monthly dataset identifier code | MV4O | MV4P | MVM2 | MV4Q | MV4R | MV4S | MV4T |
9 | 1998 | -19 | 1 | -1.2 | -2.8 | 5.4 | 1.9 | 8.4 |
10 | 1999 | -13.3 | -10 | -10.3 | -2.8 | 12.6 | 3.2 | 12 |
Table 3a
| A | B | C | D | E | F | G | H |
4 | Percentage change period on period | | | | | | | |
5 | Time period | Public new housing | Private new housing | Total new housing | Infrastructure new work | Public other new work | Private industrial new work | Private commercial new work |
6 | Annual dataset identifier code | MV5H | MV5I | MVM3 | MV5J | MV5K | MV5L | MV5M |
7 | Quarterly dataset identifier code | MV54 | MV55 | MVM7 | MV56 | MV57 | MV58 | MV59 |
8 | Monthly dataset identifier code | MV4O | MV4P | MVM2 | MV4Q | MV4R | MV4S | MV4T |
9 | 1998 | -19 | 1 | -1.2 | -2.8 | 5.4 | 1.9 | 8.4 |
10 | 1999 | -13.3 | -10 | -10.3 | -2.8 | 12.6 | 3.2 | 12 |
This works the same with multiple starting cells, example follows:
Table 3a
| A | B | C | D | E | F | G | H |
4 | Percentage change period on period | | | | | | | |
5 | Time period | Public new housing | Private new housing | Total new housing | Infrastructure new work | Public other new work | Private industrial new work | Private commercial new work |
6 | Annual dataset identifier code | MV5H | MV5I | MVM3 | MV5J | MV5K | MV5L | MV5M |
7 | Quarterly dataset identifier code | MV54 | MV55 | MVM7 | MV56 | MV57 | MV58 | MV59 |
8 | Monthly dataset identifier code | MV4O | MV4P | MVM2 | MV4Q | MV4R | MV4S | MV4T |
9 | 1998 | -19 | 1 | -1.2 | -2.8 | 5.4 | 1.9 | 8.4 |
10 | 1999 | -13.3 | -10 | -10.3 | -2.8 | 12.6 | 3.2 | 12 |
Table 3a
| A | B | C | D | E | F | G | H |
4 | Percentage change period on period | | | | | | | |
5 | Time period | Public new housing | Private new housing | Total new housing | Infrastructure new work | Public other new work | Private industrial new work | Private commercial new work |
6 | Annual dataset identifier code | MV5H | MV5I | MVM3 | MV5J | MV5K | MV5L | MV5M |
7 | Quarterly dataset identifier code | MV54 | MV55 | MVM7 | MV56 | MV57 | MV58 | MV59 |
8 | Monthly dataset identifier code | MV4O | MV4P | MVM2 | MV4Q | MV4R | MV4S | MV4T |
9 | 1998 | -19 | 1 | -1.2 | -2.8 | 5.4 | 1.9 | 8.4 |
10 | 1999 | -13.3 | -10 | -10.3 | -2.8 | 12.6 | 3.2 | 12 |
Fill
The .fill()
method works in a very similar direction to .expand()
. The only difference is the originally selected cells are not inlcuded in the final selection.
Example follows:
Table 3a
| A | B | C | D | E | F | G | H |
4 | Percentage change period on period | | | | | | | |
5 | Time period | Public new housing | Private new housing | Total new housing | Infrastructure new work | Public other new work | Private industrial new work | Private commercial new work |
6 | Annual dataset identifier code | MV5H | MV5I | MVM3 | MV5J | MV5K | MV5L | MV5M |
7 | Quarterly dataset identifier code | MV54 | MV55 | MVM7 | MV56 | MV57 | MV58 | MV59 |
8 | Monthly dataset identifier code | MV4O | MV4P | MVM2 | MV4Q | MV4R | MV4S | MV4T |
9 | 1998 | -19 | 1 | -1.2 | -2.8 | 5.4 | 1.9 | 8.4 |
10 | 1999 | -13.3 | -10 | -10.3 | -2.8 | 12.6 | 3.2 | 12 |
Table 3a
| A | B | C | D | E | F | G | H |
4 | Percentage change period on period | | | | | | | |
5 | Time period | Public new housing | Private new housing | Total new housing | Infrastructure new work | Public other new work | Private industrial new work | Private commercial new work |
6 | Annual dataset identifier code | MV5H | MV5I | MVM3 | MV5J | MV5K | MV5L | MV5M |
7 | Quarterly dataset identifier code | MV54 | MV55 | MVM7 | MV56 | MV57 | MV58 | MV59 |
8 | Monthly dataset identifier code | MV4O | MV4P | MVM2 | MV4Q | MV4R | MV4S | MV4T |
9 | 1998 | -19 | 1 | -1.2 | -2.8 | 5.4 | 1.9 | 8.4 |
10 | 1999 | -13.3 | -10 | -10.3 | -2.8 | 12.6 | 3.2 | 12 |
All directions
The supported directions are up
, down
, left
, right
, above
, below
with above and below being aliases of up and down respectively (in some scenarios they are a more natural fit).
The following is a quick example of each of the four principle directions in use with the .fill()
and expand()
operators.
F6 fill right |
D5 expand left |
D6 expand down |
F9 fill up |
Table 3a
| A | B | C | D | E | F | G | H |
4 | Percentage change period on period | | | | | | | |
5 | Time period | Public new housing | Private new housing | Total new housing | Infrastructure new work | Public other new work | Private industrial new work | Private commercial new work |
6 | Annual dataset identifier code | MV5H | MV5I | MVM3 | MV5J | MV5K | MV5L | MV5M |
7 | Quarterly dataset identifier code | MV54 | MV55 | MVM7 | MV56 | MV57 | MV58 | MV59 |
8 | Monthly dataset identifier code | MV4O | MV4P | MVM2 | MV4Q | MV4R | MV4S | MV4T |
9 | 1998 | -19 | 1 | -1.2 | -2.8 | 5.4 | 1.9 | 8.4 |
10 | 1999 | -13.3 | -10 | -10.3 | -2.8 | 12.6 | 3.2 | 12 |