MultiTable
New to Analytica 4.6. Present in experimental form in Analytica 4.5.
MultiTable(i1,i2,...)(src1, src2, ...)
A MultiTable provides a unified virtual view of multiple sources of data in a single edit table. The sources can consist of both editable tables and computed non-editable results, both depicted within the cells of a single table. When you change a cell, you are actually changing the original cell in the source, not a copy.
Best practice in Analytica modeling is generally to keep different types of information in different variables; however, you may want to present an end-user with a unified table view, with different columns depicting different items. The MultiTable gives you a way to provide such a view without sacrificing the desired practice of keeping separate data items separate.
For example, suppose Startup_cost
and Probability_success
are both edit tables, indexed by Project
. Then the MultiTable defined as:
MultiTable(Item)(Startup_cost,Probability_success)
displays both in the same edit table, indexed by Item
and Project
, and the user can edit either item directly from this view.
MultiTable is the inverse of SubTable in that MultiTable unifies multiple sources into one view, whereas SubTable is used to view or reorganize a single source.
Creating a MultiTable
Before you create a MultiTable, you need to create or identify one or more indexes that your data sources will vary over. For example, if you want a different data source to appear in each column of your table, then you'll need a column index, and you'll need to fill in the labels for each column as you define the index.
Next, create a variable to hold your MultiTable and press Ctrl+E to place your cursor in the definition field.
In the Object Finder, select the Array library and scroll down to find and select MultiTable. Then, press the Indexes button.
Select the indexes that your MultiTable data sources will vary along. These are not the indexes of your data sources themselves.
The table initially displays the "Meta expressions" view so that you can specify the data sources for the table. The meta-expression selector controls which view you are in.
Specifying Data Sources
Whenever you need to specify or change which data source should appear in a MultiTable, use the meta-expressions selector to change to meta-expressions view. For editable input variables or input tables, enter the identifier of the variable in the cell. You can also enter a Slice or Subscript expression to extract a particular slice of the data source table. The source may also be another MultiTable or SubTable.
Literal values (numbers, quoted text) is treated as a non-editable computed value. Expressions involving arithmetic operations or function calls are evaluated and the computed value shown in a non-editable form. If you want to show the computed result of a particular variable, say X
, then you need to enter Mid(X)
. If you were to enter just X
, it would show X
's definition in an editable form.
Here is an example of meta-expressions.
In the above meta-expressions view, Option_type
, Stock_symbol
, Strike_price
and Expiration_date
are identifiers of other edit tables. These will be editable columns. Stock_price_lookup(Stock_Symbol)
is a call to a User-Defined Function, and its computed value will appear in this column. The last cell contains Mid(Contract_valuation)
, so that the computed mid-value of Contract_valuation
will be displayed. When you want the computed value of a variable, you must surround its identifier with Mid in this fashion, otherwise its definition will appear in the cell and will be editable.
After you have specified the data sources in meta-expression view, change the meta-expression selector to Show Cells to see the actual data.
Displaying editable cells
To display the cells of another table, or the definition of a scalar variable, simply enter the identifier of that variable as the meta-cell source, e.g.
MultiTable(Item)(A,B)
You can also enter a Subscript or Slice expression in the cell -- the same set of expressions accepted by the SubTable function, to depict (or re-arrange) a subset of data from the original source, e.g.:
MultiTable(Item)(A[Project=SortedProject],B[Project=SortedProject])
Source tables that are Subscripted or Sliced along table indexes are depicted as editable cells.
In browse mode, data is only editable if it is associated with an input node. This means that if your MultiTable variable has an input node, then all table sources can be changed from browse mode (and thus, from Analytica Player or Cloud Player). Otherwise, if one source has an input node and another does not, then the cells corresponding to the source with the input node can be changed, while those corresponding to the other source cannot be changed from browse mode.
Displaying computed results
Computed results can be included in the same table. Cells that are computed cannot be edited, but they can sit side-by-side with editable cells. The computed values are allowed to depend on editable sources that are also depicted. Computed values are refreshed when you press the Green check button for the table.
When you enter an expression other than an identifier or a Subscripted/Sliced table, the expression is evaluated and the computed value is displayed in a read-only form. Some examples of computed sources are:
Mid(X)
: computes and displays the mid-value of XAbs(X)
: displays the absolute value of the (mid-value) of XMean(X)
: computes and displays the mean of X1.2
: displays the number, 1.2, in a non-editable cell"Some text"
: displays the text, without quotes, in a non-editable cell
Here is an example of an editable value and computed value in the same table:
Index Base := ["Decimal", "Hex"] Variable x := 123 Variable HexConverter := MultiTable(Base)(x,NumberToText(x,"Hexadecimal"))
The edit table displays like this:
The first cell can be edited, and when you change it and press the green check, the Hex value is computed and displayed.
Dimensionality
The dimensions of the MultiTable content are the union of the indexes from all sources and of the MultiTable index(es).
A MultiTable works best when your sources all have the same dimensionality. When one source does not have an index present in another source, a single cell in the source will map to multiple cells in the MultiTable; hence, you'll see the same value multiple places, and when you change it, multiple cells will change. The source retains its original dimensionality, so if the value doesn't vary along an index in the source, it won't vary along that index is the MultiTable. You may temporarily see a difference in these cells after you first enter a value, but they will become consistent as soon as you press the Green check.
Number Formats
TBD
Units
TBD
Enable comment auto-refresher