 <?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.analytica.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Dlogan</id>
	<title>Analytica Docs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.analytica.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Dlogan"/>
	<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php/Special:Contributions/Dlogan"/>
	<updated>2026-06-09T04:11:46Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.9</generator>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Copy_and_Paste_between_applications&amp;diff=52498</id>
		<title>Copy and Paste between applications</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Copy_and_Paste_between_applications&amp;diff=52498"/>
		<updated>2019-01-24T04:24:51Z</updated>

		<summary type="html">&lt;p&gt;Dlogan: /* Copy and Past Data from a Spreadsheet into Analytica */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category: Analytica User Guide]]&lt;br /&gt;
&amp;lt;breadcrumbs&amp;gt; Analytica User Guide &amp;gt; Integration with data and applications &amp;gt; {{PAGENAME}}&amp;lt;/breadcrumbs&amp;gt;&lt;br /&gt;
{{ReleaseBar}}&lt;br /&gt;
&lt;br /&gt;
;&lt;br /&gt;
You can use the standard '''Copy''' and '''Paste''' commands from the  [[Edit menu]] or the equivalent keyboard shortcuts, Ctrl+v and Ctrl+c, in most situations you would expect.  &lt;br /&gt;
&lt;br /&gt;
== Copy and Paste tabular data ==&lt;br /&gt;
&lt;br /&gt;
===Copy cell(s) from an Analytica Result or Edit table===&lt;br /&gt;
&lt;br /&gt;
# Open the window containing the table.&lt;br /&gt;
# Select a cell, or rectangular range of cells.&lt;br /&gt;
# Select '''Copy''' from the [[Edit menu]] or press ''Control+c''.&lt;br /&gt;
# Select the top-left cell (or a cell-range of the same size as you copied) in the same or another table in Analytica or in another table-based application, such as Microsoft Excel. &lt;br /&gt;
# Select '''Paste''' from the [[Edit menu]] or press ''Control+v''.&lt;br /&gt;
&lt;br /&gt;
===Copy All the Elements of a Table in Addition to the Index Elements===&lt;br /&gt;
&lt;br /&gt;
If you want to copy an entire table, including row and column headers, and all slices if it has more than two dimension:&lt;br /&gt;
&lt;br /&gt;
# Select '''Copy Table''' from the [[Edit menu]]. &lt;br /&gt;
&lt;br /&gt;
You can paste this into another table-based application, like Microsoft Excel.&lt;br /&gt;
&lt;br /&gt;
===Copy and Paste Data from a Spreadsheet into Analytica===&lt;br /&gt;
&lt;br /&gt;
This is almost the same as copying data within or between spreadsheets:&lt;br /&gt;
&lt;br /&gt;
# Select a group of cells in a spreadsheet.&lt;br /&gt;
# Select '''Copy''' from that program’s [[Edit menu]] (''Control+c'') to copy the data to the clipboard.&lt;br /&gt;
# Bring the Analytica model to the front and open the '''Edit Table''' window you want to paste the data into.&lt;br /&gt;
# Select a top-left cell or the same number of cells that you originally copied.&lt;br /&gt;
# Select '''Paste''' from the [[Edit menu]] (''Control+v'')&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tip title=&amp;quot;Tip&amp;quot;&amp;gt;You may need to pivot the Analytica table first to make sure the rows and columns are arranged in the same way as the original table.  When copying a row of data from a spreadsheet into a one-dimensional table, transpose the data first so that you are copying it as a column of cells, not a row of cells.&amp;lt;/Tip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Paste Data from Another Application===&lt;br /&gt;
&lt;br /&gt;
To paste data from a program other than a spreadsheet:&lt;br /&gt;
&lt;br /&gt;
* Use tab characters to separate items, and return characters to separate lines.&lt;br /&gt;
* It accepts numbers in most common formats, including exponential, currency symbols and commas separate thousands. You can use the suffixes that Analytica recognizes, including &amp;lt;code&amp;gt;K&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;M&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
=== Quoted values ===&lt;br /&gt;
When pasting data into tables or fields within Analytica, quotations are sometimes added around content. The general rule for when quotations are added is this:&lt;br /&gt;
* Quotes are added to content when the source of content is not a field that holds Analytica expressions, but the source expects an expression. &lt;br /&gt;
The rule has the effect that when you evaluate the target, the result has the same value as the source data. Some consequences of this rule are&lt;br /&gt;
* When pasting from a Definition to a Definition, quotes are neither added nor removed.&lt;br /&gt;
* When pasting from a Description (which is not an expression) to a Definition, quotes are added. The result of evaluating the variable is then the same as the Description text.&lt;br /&gt;
* When pasting from an external text editor into a Definition, quotes are added.&lt;br /&gt;
* When pasting from an external text editor into a Description field, quotes are not added.&lt;br /&gt;
&lt;br /&gt;
{{Release|5.0||You may encounter cases where you didn't want the quotes to be added for you. When this happens, select the table cells and select '''Remove quotes when possible''' from the right-mouse context menu.}}&lt;br /&gt;
&lt;br /&gt;
== Copy and Paste Diagrams and Graphs ==&lt;br /&gt;
&lt;br /&gt;
===Copy Nodes from a Diagram===&lt;br /&gt;
&lt;br /&gt;
# [[Selecting nodes|Select a node or group of nodes]] from a Diagram (in Browse or Edit mode).&lt;br /&gt;
# Select '''Copy''' from the [[Edit menu]] or press ''Control+c''. &lt;br /&gt;
# Click a location in the same or another Analytica Diagram or in another application, for example a Microsoft Word document, and Select '''Paste''' from the [[Edit menu]] or press ''Control+v''. &lt;br /&gt;
&lt;br /&gt;
If you paste the results into an Analytica diagram window (the original diagram or another), it creates new nodes into that diagram with their underlying variables or other objects.  It adds a digit to each identifier to distinguish them from the original objects that you copied. It retains any influence relationships among the objects.  If you past a module node, it copies all objects inside that module (and any submodules recursively).&lt;br /&gt;
&lt;br /&gt;
If you paste copied nodes into another application, like Microsoft Word, Power Point, or Excel, it pastes a picture of the nodes and any influence arrows. &lt;br /&gt;
&lt;br /&gt;
===Copy an Entire Influence Diagram ===&lt;br /&gt;
&lt;br /&gt;
With a Diagram window active, select '''Copy Diagram''' from the [[Edit menu]]. It copies the influence diagram as a picture but not the objects that the nodes represent.&lt;br /&gt;
&lt;br /&gt;
===Copy a Result Graph===&lt;br /&gt;
&lt;br /&gt;
This is useful if you want to create a document or presentation using graphs from an Analytica model:&lt;br /&gt;
&lt;br /&gt;
# Open a [[Result window]] showing the graph.&lt;br /&gt;
# Select '''Copy''' from the [[Edit menu]] or ''Control+c''&lt;br /&gt;
# Click a location in the document of another application, such as Microsoft Word or Powerpoint.&lt;br /&gt;
# Select '''Paste''' from the [[Edit menu]] or press ''Control+v''.&lt;br /&gt;
&lt;br /&gt;
This pastes a picture of the graph into the document.&lt;br /&gt;
&lt;br /&gt;
==Export Diagram or Graph to image file==&lt;br /&gt;
&lt;br /&gt;
For greater flexibility, you can use the ''Export''' from the [[File menu]] to export a Diagram or Graph into an image file. In each case, it prompts you for the desired image format, including EMF, PNG, JPEG, BMP, and TIFF.&lt;br /&gt;
&lt;br /&gt;
===Export Diagram as an Image File===&lt;br /&gt;
&lt;br /&gt;
# With the diagram showing, select '''Export''' from the [[File menu]]. &lt;br /&gt;
# From the '''Save''' dialog, select the desired format. &lt;br /&gt;
&lt;br /&gt;
It stores an image of the full diagram (not just the selected nodes).&lt;br /&gt;
&lt;br /&gt;
===Export a Result Graph as an Image File===&lt;br /&gt;
 &lt;br /&gt;
# Open the [[Result window]] containing the graph.&lt;br /&gt;
# Select '''Export''' from the [[File menu]] and select the desired image file format.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Analytica User FAQs/Application Integration]]&lt;br /&gt;
* [[Model file formats]]&lt;br /&gt;
* [[Excel to Analytica Translation]]&lt;br /&gt;
* [[Diagram window]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;footer&amp;gt;Integration with data and applications / {{PAGENAME}} / Read and write text files&amp;lt;/footer&amp;gt;&lt;/div&gt;</summary>
		<author><name>Dlogan</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Self-Indexed_Arrays&amp;diff=50925</id>
		<title>Self-Indexed Arrays</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Self-Indexed_Arrays&amp;diff=50925"/>
		<updated>2017-11-27T22:59:42Z</updated>

		<summary type="html">&lt;p&gt;Dlogan: /* Create a self-indexed variable */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[category:Arrays]]&lt;br /&gt;
[[Category:Doc Status C]] &amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each dimension of an array is identified by an Index. Usually, each index is defined as an index object, which appears in a Diagram like this:&lt;br /&gt;
&lt;br /&gt;
:[[image:IndexNode.jpg]]&lt;br /&gt;
&lt;br /&gt;
But, it's also possible for a standard variable to contain an index value in addition to its actual value.  This index value is called a &amp;quot;Self index&amp;quot; because the actual array value of the variable is indexed by the variable's own index value. An array value of another variable may also use the self index of this variable. Self-indexes can arise and be useful in several situations.&lt;br /&gt;
&lt;br /&gt;
== Create a self-indexed variable ==&lt;br /&gt;
&lt;br /&gt;
Here's one way to create a self-indexed variable:  &lt;br /&gt;
&lt;br /&gt;
First, drag a variable node to the diagram and name it &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;.  Press the [[image:Expr.jpg]] button on the toolbar to edit the definition and select &amp;quot;Table&amp;quot; from the definition type dropdown:&lt;br /&gt;
&lt;br /&gt;
:[[image:CreateTable.JPG]]&lt;br /&gt;
&lt;br /&gt;
In the index chooser dialog, select the &amp;quot;X (Self)&amp;quot; index and press OK.&lt;br /&gt;
&lt;br /&gt;
:[[image:SelectSelfIndex.jpg]]&lt;br /&gt;
&lt;br /&gt;
You have now just created an edit table with a self index.&lt;br /&gt;
&lt;br /&gt;
:[[image:SelfIndexedTable.jpg]]&lt;br /&gt;
&lt;br /&gt;
Notice that the row-index is &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, and the edit table itself is for &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;.  Here the row headings are the index values for &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, the table body cells hold the main value for &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;.  Next, fill in both the self-index value and the body cells with values, as follows.&lt;br /&gt;
&lt;br /&gt;
:[[image:SelfIndexedTable2.jpg]]&lt;br /&gt;
&lt;br /&gt;
As we see here, the variable's self-index value is usually different from its actual value.&lt;br /&gt;
&lt;br /&gt;
== Expression Context ==&lt;br /&gt;
&lt;br /&gt;
When a variable has both a main value and an index value, what happens when its identifier is used in an expression?  (Side note: In general, a variable may have a [[Mid]] value and a probabilistic, or sample, value.  See [[Evaluation Modes]] for more detail.  Here we refer to either of these as the main value.)&lt;br /&gt;
&lt;br /&gt;
As it turns out, Analytica can determine whether to use the main value or the index value based on the context in which the identifier appears.  A simple example is this:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Sum(X, X)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This expressions sums the value of «X» along the «X» index.  So, when «X» is a self-indexed variable, the main value is used for the first parameter, and its self-index value is used for the second parameter.&lt;br /&gt;
&lt;br /&gt;
In general, the parameters of a function (whether built-in or user-defined) are declared using various [[Function Parameter Qualifiers]].  When a parameter is declared using the [[Function Parameter Qualifiers#IndexType|IndexType]] qualifier, then identifiers passed for that parameter are interpreted as indexes.  Parameters that are declare otherwise are interpreted as values.  (Note: There are further subtleties involved when a parameter is declared as a [[Function Parameter Qualifiers#VariableType|VariableType]], which are beyond the scope of this introduction).  &lt;br /&gt;
&lt;br /&gt;
== The IndexType qualifier ==&lt;br /&gt;
&lt;br /&gt;
When you define your own user-defined function (UDF), you might declare a parameter to be an index.  This creates a local variable that is an alias for the index that is passed in.  If this local variable is used in a value context, the index value (and not the main value) is used.  So, for example, consider the following function:&lt;br /&gt;
&lt;br /&gt;
:[[image:JoinIndex.jpg]]&lt;br /&gt;
&lt;br /&gt;
Suppose, using the self-indexed array defined earlier, we call this function using [[JoinIndex]]():&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;JoinIndex(X)&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
The result obtained is:  &lt;br /&gt;
:&amp;lt;code&amp;gt;&amp;quot;one, two, three, four&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Compare this to what we would get by evaluating [[Join]]() in &amp;lt;/code&amp;gt;Join( X, X,' ,')&amp;lt;/code&amp;gt;, which results in &amp;quot;15,12,13,8&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Three [[:category:Special Functions|special functions]] exist to explicit control which value to use from within an expression.  These are applicable to expressions being evaluated in a value context.  These are: [[Mid]], [[Sample]] and [[IndexValue]].  The [[Mid]] and [[Sample]] functions provide access to the main values of the variable (see [[Evaluation Modes]] for the distinction), while the [[IndexValue]] function returns the index value.  Using the [[IndexValue]] function, we could for example join the index value of &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; using&lt;br /&gt;
:&amp;lt;code&amp;gt;Join(IndexValue(X), X, &amp;quot;,&amp;quot;)&amp;lt;/code&amp;gt;&lt;br /&gt;
yielding &lt;br /&gt;
:&amp;lt;code&amp;gt;''&amp;quot;one, two, three, four&amp;quot;''&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Copy Index ==&lt;br /&gt;
Using the &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; variable defined above, suppose we wish to define an index, &amp;lt;code&amp;gt;J&amp;lt;/code&amp;gt;, having the same values that &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; has.  We now have two choices - should this new index be composed of &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;'s index values, i.e., &amp;lt;code&amp;gt;['one', 'two', 'three', 'four']&amp;lt;/code&amp;gt;, or of &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;'s result values, i.e., &amp;lt;code&amp;gt;[15,12,13, 8]&amp;lt;/code&amp;gt;?  Either is possible:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;CopyIndex(X)             &amp;amp;rarr;  [15, 12, 13, 8]&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;CopyIndex( IndexValue(X) ) &amp;amp;rarr; ['one', 'two', 'three', 'four']&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: There are several alternative ways of copying the index value.  The [[IndexValue]] function is new to Analytica 4.0, but for earlier versions one could use&lt;br /&gt;
:&amp;lt;code&amp;gt;Subset(Array(X,1))       &amp;amp;rarr;  ['one', 'two', 'three', 'four']&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== List Definitions ==&lt;br /&gt;
&lt;br /&gt;
A second way that index values often arise in Analytica is by defining a variable as a list of identifiers, or as a list of expressions.  This is often very convenient when creating a report, bringing several results together in a single table view.&lt;br /&gt;
&lt;br /&gt;
:[[image:Cash_flow_stmt_definition.jpg]]&lt;br /&gt;
&lt;br /&gt;
The variable shown in the preceding screenshot is defined as a list of identifiers.  When this variable is evaluated, it has both a self-index (the list of identifiers) and a value, obtained by evaluating each of the variables appearing in the table and joining them into a single array.&lt;br /&gt;
&lt;br /&gt;
In this model, most of the variables appearing in the list evaluate to a result that is indexed by [[Time]].  Therefore, the value obtained is two-dimensional, indexed by itself (&amp;lt;code&amp;gt;Cash_flow_statement&amp;lt;/code&amp;gt;) and by [[Time]].&lt;br /&gt;
&lt;br /&gt;
:[[image:Cash_flow_stmt_result.jpg]]&lt;br /&gt;
&lt;br /&gt;
Side note: When Analytica displays a self-indexed result, and the self-index is composed of object identifiers, then Analytica uses separate number formats for each row (or column if pivoted), taking the number format for the corresponding row from the identifier that appears in the self-index.  This provides a capability to format each row of a table differently.&lt;br /&gt;
&lt;br /&gt;
The value of &amp;lt;code&amp;gt;IndexValue(Cash_flow_statement)&amp;lt;/code&amp;gt; in this example is composed of a list of [[varTerm]]s, essentially handles to Analytica objects.  In advanced Analytica modeling, these varTerms can be utilized for meta-level inference and button scripting (performing inference about the model itself).  Meta-level inference is beyond the scope of the current article, but we point this out for readers who may already be at this level of expertise.  &lt;br /&gt;
&lt;br /&gt;
== Self-Indexes from the Domain ==&lt;br /&gt;
When the domain attribute contains an explicit list, either a list of expressions, list of labels, or index-domain, Analytica treats the domain value as the variable's self-index.  This is often used when defining a [[Choice]] definition, [[DetermTable]] or [[ProbTable]] definition.  For example, in a ProbTable, the main value (usually the [[Sample]]) is the randomly-sampled set of values, but the [[IndexValue]] for the variable is the set of all possible values.&lt;br /&gt;
&lt;br /&gt;
The domain values can also be accessed using:&lt;br /&gt;
:&amp;lt;code&amp;gt;domain of X&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should be noticed that the treatment of the domain value as a self-index value is a functionality that [http://lumina.com Lumina] plans to eventually eliminate.  If you wish to refer to the domain value of a variable, it is preferable to use &amp;quot;domain of X&amp;quot; rather than [[IndexValue]](X) to ensure forward compatibility with future releases of Analytica.&lt;br /&gt;
&lt;br /&gt;
The use of the domain in a [[Choice]] definition, or to index a [[DetermTable]] or [[ProbTable]] will continue to be valid in future releases.  However, when the changes we envision are eventually enacted, we could allow for the possibility of a multi-select [[Choice]] control, for example.  In such a case, the main and index values could be a subset of the domain value.&lt;br /&gt;
&lt;br /&gt;
Note: Few models utilize the domain of a variable as a self-index outside their use of [[Choice]](Self, n), [[DetermTable]] or [[ProbTable]], so this change only impacts models that do fairly unusual things.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Self]]&lt;br /&gt;
* [[Index]]&lt;br /&gt;
* [[Array]]&lt;br /&gt;
* [[IndexValue]]&lt;br /&gt;
* [[Domain Indexes]]&lt;/div&gt;</summary>
		<author><name>Dlogan</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Self-Indexed_Arrays&amp;diff=50924</id>
		<title>Self-Indexed Arrays</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Self-Indexed_Arrays&amp;diff=50924"/>
		<updated>2017-11-27T22:52:58Z</updated>

		<summary type="html">&lt;p&gt;Dlogan: /* Create a self-indexed variable */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[category:Arrays]]&lt;br /&gt;
[[Category:Doc Status C]] &amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Each dimension of an array is identified by an Index. Usually, each index is defined as an index object, which appears in a Diagram like this:&lt;br /&gt;
&lt;br /&gt;
:[[image:IndexNode.jpg]]&lt;br /&gt;
&lt;br /&gt;
But, it's also possible for a standard variable to contain an index value in addition to its actual value.  This index value is called a &amp;quot;Self index&amp;quot; because the actual array value of the variable is indexed by the variable's own index value. An array value of another variable may also use the self index of this variable. Self-indexes can arise and be useful in several situations.&lt;br /&gt;
&lt;br /&gt;
== Create a self-indexed variable ==&lt;br /&gt;
&lt;br /&gt;
Here's one way yo create a self-indexed variable:  &lt;br /&gt;
&lt;br /&gt;
First, drag a variable node to the diagram and name it &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;.  Press the [[image:Expr.jpg]] button on the toolbar to edit the definition and select &amp;quot;Table&amp;quot; from the definition type dropdown:&lt;br /&gt;
&lt;br /&gt;
:[[image:CreateTable.JPG]]&lt;br /&gt;
&lt;br /&gt;
In the index chooser dialog, select the &amp;quot;X (Self)&amp;quot; index and press OK.&lt;br /&gt;
&lt;br /&gt;
:[[image:SelectSelfIndex.jpg]]&lt;br /&gt;
&lt;br /&gt;
You have now just created an edit table with a self index.&lt;br /&gt;
&lt;br /&gt;
:[[image:SelfIndexedTable.jpg]]&lt;br /&gt;
&lt;br /&gt;
Notice that the row-index is &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, and the edit table itself is for &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;.  Here the row headings are the index values for &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, the table body cells hold the main value for &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;.  Next, fill in both the self-index value and the body cells with values, as follows.&lt;br /&gt;
&lt;br /&gt;
:[[image:SelfIndexedTable2.jpg]]&lt;br /&gt;
&lt;br /&gt;
As we see here, the variable's self-index value is usually different from its actual value.&lt;br /&gt;
&lt;br /&gt;
== Expression Context ==&lt;br /&gt;
&lt;br /&gt;
When a variable has both a main value and an index value, what happens when its identifier is used in an expression?  (Side note: In general, a variable may have a [[Mid]] value and a probabilistic, or sample, value.  See [[Evaluation Modes]] for more detail.  Here we refer to either of these as the main value.)&lt;br /&gt;
&lt;br /&gt;
As it turns out, Analytica can determine whether to use the main value or the index value based on the context in which the identifier appears.  A simple example is this:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Sum(X, X)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This expressions sums the value of «X» along the «X» index.  So, when «X» is a self-indexed variable, the main value is used for the first parameter, and its self-index value is used for the second parameter.&lt;br /&gt;
&lt;br /&gt;
In general, the parameters of a function (whether built-in or user-defined) are declared using various [[Function Parameter Qualifiers]].  When a parameter is declared using the [[Function Parameter Qualifiers#IndexType|IndexType]] qualifier, then identifiers passed for that parameter are interpreted as indexes.  Parameters that are declare otherwise are interpreted as values.  (Note: There are further subtleties involved when a parameter is declared as a [[Function Parameter Qualifiers#VariableType|VariableType]], which are beyond the scope of this introduction).  &lt;br /&gt;
&lt;br /&gt;
== The IndexType qualifier ==&lt;br /&gt;
&lt;br /&gt;
When you define your own user-defined function (UDF), you might declare a parameter to be an index.  This creates a local variable that is an alias for the index that is passed in.  If this local variable is used in a value context, the index value (and not the main value) is used.  So, for example, consider the following function:&lt;br /&gt;
&lt;br /&gt;
:[[image:JoinIndex.jpg]]&lt;br /&gt;
&lt;br /&gt;
Suppose, using the self-indexed array defined earlier, we call this function using [[JoinIndex]]():&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;JoinIndex(X)&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
The result obtained is:  &lt;br /&gt;
:&amp;lt;code&amp;gt;&amp;quot;one, two, three, four&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Compare this to what we would get by evaluating [[Join]]() in &amp;lt;/code&amp;gt;Join( X, X,' ,')&amp;lt;/code&amp;gt;, which results in &amp;quot;15,12,13,8&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Three [[:category:Special Functions|special functions]] exist to explicit control which value to use from within an expression.  These are applicable to expressions being evaluated in a value context.  These are: [[Mid]], [[Sample]] and [[IndexValue]].  The [[Mid]] and [[Sample]] functions provide access to the main values of the variable (see [[Evaluation Modes]] for the distinction), while the [[IndexValue]] function returns the index value.  Using the [[IndexValue]] function, we could for example join the index value of &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; using&lt;br /&gt;
:&amp;lt;code&amp;gt;Join(IndexValue(X), X, &amp;quot;,&amp;quot;)&amp;lt;/code&amp;gt;&lt;br /&gt;
yielding &lt;br /&gt;
:&amp;lt;code&amp;gt;''&amp;quot;one, two, three, four&amp;quot;''&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Copy Index ==&lt;br /&gt;
Using the &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; variable defined above, suppose we wish to define an index, &amp;lt;code&amp;gt;J&amp;lt;/code&amp;gt;, having the same values that &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; has.  We now have two choices - should this new index be composed of &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;'s index values, i.e., &amp;lt;code&amp;gt;['one', 'two', 'three', 'four']&amp;lt;/code&amp;gt;, or of &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;'s result values, i.e., &amp;lt;code&amp;gt;[15,12,13, 8]&amp;lt;/code&amp;gt;?  Either is possible:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;CopyIndex(X)             &amp;amp;rarr;  [15, 12, 13, 8]&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;CopyIndex( IndexValue(X) ) &amp;amp;rarr; ['one', 'two', 'three', 'four']&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: There are several alternative ways of copying the index value.  The [[IndexValue]] function is new to Analytica 4.0, but for earlier versions one could use&lt;br /&gt;
:&amp;lt;code&amp;gt;Subset(Array(X,1))       &amp;amp;rarr;  ['one', 'two', 'three', 'four']&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== List Definitions ==&lt;br /&gt;
&lt;br /&gt;
A second way that index values often arise in Analytica is by defining a variable as a list of identifiers, or as a list of expressions.  This is often very convenient when creating a report, bringing several results together in a single table view.&lt;br /&gt;
&lt;br /&gt;
:[[image:Cash_flow_stmt_definition.jpg]]&lt;br /&gt;
&lt;br /&gt;
The variable shown in the preceding screenshot is defined as a list of identifiers.  When this variable is evaluated, it has both a self-index (the list of identifiers) and a value, obtained by evaluating each of the variables appearing in the table and joining them into a single array.&lt;br /&gt;
&lt;br /&gt;
In this model, most of the variables appearing in the list evaluate to a result that is indexed by [[Time]].  Therefore, the value obtained is two-dimensional, indexed by itself (&amp;lt;code&amp;gt;Cash_flow_statement&amp;lt;/code&amp;gt;) and by [[Time]].&lt;br /&gt;
&lt;br /&gt;
:[[image:Cash_flow_stmt_result.jpg]]&lt;br /&gt;
&lt;br /&gt;
Side note: When Analytica displays a self-indexed result, and the self-index is composed of object identifiers, then Analytica uses separate number formats for each row (or column if pivoted), taking the number format for the corresponding row from the identifier that appears in the self-index.  This provides a capability to format each row of a table differently.&lt;br /&gt;
&lt;br /&gt;
The value of &amp;lt;code&amp;gt;IndexValue(Cash_flow_statement)&amp;lt;/code&amp;gt; in this example is composed of a list of [[varTerm]]s, essentially handles to Analytica objects.  In advanced Analytica modeling, these varTerms can be utilized for meta-level inference and button scripting (performing inference about the model itself).  Meta-level inference is beyond the scope of the current article, but we point this out for readers who may already be at this level of expertise.  &lt;br /&gt;
&lt;br /&gt;
== Self-Indexes from the Domain ==&lt;br /&gt;
When the domain attribute contains an explicit list, either a list of expressions, list of labels, or index-domain, Analytica treats the domain value as the variable's self-index.  This is often used when defining a [[Choice]] definition, [[DetermTable]] or [[ProbTable]] definition.  For example, in a ProbTable, the main value (usually the [[Sample]]) is the randomly-sampled set of values, but the [[IndexValue]] for the variable is the set of all possible values.&lt;br /&gt;
&lt;br /&gt;
The domain values can also be accessed using:&lt;br /&gt;
:&amp;lt;code&amp;gt;domain of X&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should be noticed that the treatment of the domain value as a self-index value is a functionality that [http://lumina.com Lumina] plans to eventually eliminate.  If you wish to refer to the domain value of a variable, it is preferable to use &amp;quot;domain of X&amp;quot; rather than [[IndexValue]](X) to ensure forward compatibility with future releases of Analytica.&lt;br /&gt;
&lt;br /&gt;
The use of the domain in a [[Choice]] definition, or to index a [[DetermTable]] or [[ProbTable]] will continue to be valid in future releases.  However, when the changes we envision are eventually enacted, we could allow for the possibility of a multi-select [[Choice]] control, for example.  In such a case, the main and index values could be a subset of the domain value.&lt;br /&gt;
&lt;br /&gt;
Note: Few models utilize the domain of a variable as a self-index outside their use of [[Choice]](Self, n), [[DetermTable]] or [[ProbTable]], so this change only impacts models that do fairly unusual things.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Self]]&lt;br /&gt;
* [[Index]]&lt;br /&gt;
* [[Array]]&lt;br /&gt;
* [[IndexValue]]&lt;br /&gt;
* [[Domain Indexes]]&lt;/div&gt;</summary>
		<author><name>Dlogan</name></author>
	</entry>
</feed>