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.

This feature is available in the Chart, Dashboard, Explorer, Spreadsheet, and Table applications.

Getting Started

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.

  1. Create the document.
    1. Open Chart.
    2. Enter GOOG, GOOG.bollinger(), and GOOG.volume() in the expression bar. Move GOOG.volume() to a subplot and switch the renderer to a bar graph.
  2. Switch to the Variables perspective.
  3. In order to bind the instrument GOOG to a variable, check the box for GOOG under Other. Notice that the Variables sidebar now lists GOOG as a variable and states that it is used in 3 locations in the document. Additionally, because there are two other expressions that rely on GOOG, two other variables are created, both referencing that first GOOG variable.
  4. To now replace GOOG with MSFT, click GOOG in the Variables sidebar and enter MSFT.

    Return to the Home perspective and notice that Microsoft data has replaced all of the Google data.

Basic Reference

Variables Perspective

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.

Summary Tab

The Summary tab organizes possible variables in your document into five categories:

  • Documents - Lists all the documents that the current document is using. For instance, if you created a Dashboard based on an Explorer Group, the Explorer Group will show up here as a document that can be bound as a variable.
  • Collections - Lists all the collections that are in the document.
  • Metrics - Lists all the metrics that are in the document.
  • Strings - Lists all the Strings that are in the document.
  • Other - Lists all other expressions that are in the documents (such as instruments, numbers, ranges, or Enum parameters).

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.

Tree Tab

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:

  1. Open Dashboard.
    1. Add a Chart widget with GOOG and GOOG.ma() on one plot and AAPL on a subplot.
    2. Add a Table widget with rows containing MSFT, GOOG, and AAPL and columns consisting of hvol(), volume(), and marketcap().
  2. Switch to the Variables perspective and click the Tree tab at the bottom of the screen.
  3. In the Variables tab, click Collapse.

    The tree will collapse to show only the highest level nodes: in this case, it will show nodes for the two widgets, Chart and Table.
  4. Click to expand the Chart node. The tree will now display branches to each dataset (each plotted item).
  5. Click to expand the node, Plot 1 - Dataset 2 and then the node Expression. The node will branch into its most basic components: GOOG and ma.

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.

Variables Sidebar

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.

Variables Tab

  • Search Tree Panel - Contains options to search for objects in the tree (simply enter the name of the node you are interested in) and subsequently bind them by clicking Create variable from selected.
  • View Options Panel - Contains options to expand or collapse your tree.
  • Variable rows - Contains options to combine multiple selected variables into one variable bound to multiple locations, or to split a variable bound to multiple locations into separate, independent variables.
  • Restrict Values to Collection - Contains options to add a collection of possible values for a variable.

Concepts and Features

Arbitrary Expression Replacement

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:

  1. Open Chart and enter AMZN.hvol(60)
  2. In the Tree View of the Variables perspective, bind AMZN as a variable.
  3. The first variable is created for AMZN with the name expression1. The second variable, called expression2, is also created and is set to the value expression1.hvol(60). Notice that this is the full expression (AMZN.hvol(60)), but instead of explicitly referencing AMZN, it refers to the variable we created for AMZN. Also note that this second variable is hidden by default; to display the variable in the Home perspective, uncheck Hide.
  4. Switch back to the Home perspective. expression1 accepts variables of type Stock (because AMZN is of type Stock) as well as the parent type (in this case, Time Series. For more information about types, see Model Type Hierarchy). Meaning you can replace the value of expression1 to any expression that returns a time series. For example, replace the value of expression1 with GOOG.correl(MSFT). Since this returns a time series, it is a valid replacement and the chart updates to show the plot of GOOG.correl(MSFT).hvol(60).

Previous Versions

Variables Perspective 3.18

Arbitrary Expression Replacement

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.

Child Documents Only Loaded On Demand

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.

Related Links

Need Help? Email us at           © 2014 Palantir Technologies  ·  Terms of Use  ·  Privacy and Security Statement