|Metropolis Documentation 4.3 > Platform Concepts > The Document Sidebar > The Variables Perspective|
The Variables Perspective feature lets you swap values in and out of existing documents by binding the various instruments, metrics, and other values as variables. For example, if you open a Chart document that contains the datasets GOOG.ma() and GOOG.bollinger(), you can bind the instrument GOOG to a variable, and then change its value to MSFT. This lets you use existing documents as templates to quickly perform similar or related analysis without recreating documents from scratch.
To illustrate the power of Templates, let's look at a simple example using Chart. In this example you will create a chart with GOOG, GOOG.bollinger(), and GOOG.volume(); you will then bind GOOG as a variable and swap it for MSFT.
The Variables perspective lets you bind elements in the document to variables and then change their values. The Variables perspective contains two possible views: Summary and Tree. Click the tabs found at the bottom of the screen to switch between views.
The Summary tab organizes possible variables in your document into five categories:
To bind an object to a variable, click the check-box next to the object's name.
If you create a chart GOOG and GOOG.ma(), both expressions will be listed under Other. The GOOG, however, will be listed as being in two locations, because the Google model is used in two expressions. Click locations... to see a list of each individual instance of the object. This gives you the option of binding all the instances of an object to a single variable, or selecting specific instances to bind to the variable.
The Tree tab displays all of the possible variables in your document as both a list and a tree. This view is divided into two panels. The left panel contains a list of all the objects in your document (they are categorized by their Value, Name, and how many times they appear in the document). The right panel displays the tree (hierarchy) of all the objects (and lists the Node, Current Value, Variable Name, and Bound Value).
The tree is constructed such that each component of a document branches into its base parts, starting with the top-most layer of the document and working down. The easiest way to understand this it to look at a simple example:
To bind an object to a variable, double-click on the desired node or value in the list. Alternatively, if you right-click on a node, you have the option of creating a new variable or of binding that object to a pre-existing variable.
The Variables sidebar displays all the variables in the current document and lets you modify their values. The sidebar is accessible from any perspective, not just the Variables perspective. You can access it by clicking the very right-hand side of the window, much like you would access the Documents sidebar on the left side of the window.
When you bind any sub-expression in the Variable’s Perspective, two variables are created. The first variable is bound as that sub-expression; the second variable consists of the full expression, but dependent on the first variable (in other words, the sub-expression is referred to by its variable instead its value).
This feature leads to more flexibility as to what values are accepted as replacement values: instead of a variable recognizing values only of the exact same type (e.g. a Stock for AMZN), the variable also accepts parent types (e.g. any expression that returns a time series, because Stock is a child of TimeSeries).
The best way to understand this feature is through an example:
When you bind a portion of an expression to a variable, previously you could only replace it with expressions that evaluated to the same type as the original. Now, two variables are now created. The first variable will be set to the portion of the expression you bound, as in previous versions. The second variable will be set to the entire expression, except the selected subexpression will be replaced by the first variable. This makes the second variable dependent on the first variable.
This allows you to replace the selection with any arbitrary expression, though if the result isn't valid Hedgehog code, you will get an error.
By default, the system no longer loads all child documents automatically. Instead, use the Load Document Nodes option in the Variable ribbon to load these documents.
For more information about what is new in the platform, see Version History.