Error Messages/40259
Examples:
In call to function Sum, the second parameter, I, is not a valid index.
General form:
In call to function %1%, the %2% parameter, %3%, is not a valid index.
What caused it?
The indicated parameter does not identify a valid index.
For a variable to be valid as an index, it must either evaluate to a list of elements, or it must have a self-index.
There are several ways in which a variable might have a self-index:
- It could be a self-indexed table (where Self is being used as one of the table dimensions). In this case, the index values are placed in the IndexVals attribute.
- When the definition evaluates to a result that contains an implicit dimension, the implicit dimension is promoted to be a self-index. An implicit dimension is created when your expression operates over an explicit list, or over the result of function that returns a list, such as Sequence, Subset, SplitText, or Unique.
- If you are using Analytica 4.2 or earlier, or if you are using Analytica 4.3 and have the Domain as Self-Index preference checked, then a self-index is introduced when the domain is set to be a list or a list-of numbers. If you've load a model that was originally build pre-4.3 into Analytica 4.3, this preference will be checked. If you have subsequently turned off that check, it could result in this error.
Note that the variable identified by «I» does not have to be an index object (i.e., it does not have to be a parallelogram on an influence diagram).
Notes on the Domain as Self-Index Preference
If you have recently migrated your model from 4.2 or earlier into Analytica 4.3, then you might see this error as the result of 4.3's cleaner domain semantics. To illustrate, consider the following scenario.
Variable A := Choice(Self,1) Domain A := ['apple','banana','cherry','date'] Variable B := Choice(A,1)
Prior to Analytica 4.3, Analytica would be perfectly happy with Variable B. Its set of choices are pulled from the domain of A. However, on inspection, this is a bit strange. Variable A is actually defined to be a single value -- essentially it is "apple". So why should A be considered to be a valid index for the call to Choice in B? The Domain of A specified the possible values of A, but not the actual value of A. This usage of domain of A as a self-index created a confused semantics over exactly what the domain attribute means.
Analytica 4.3 cleans up this semantics -- the domain of A is the set of values that Variable A can take on -- and is not the actual value of A. Hence, when Variable A is defined as "apple" (or as Choice(Self,1)
, which is equivalent to "apple"), then Variable A is scalar-valued, and is not a valid index.
When you are starting fresh, this cleaner semantics for the domain of A is to be preferred. But as you can see, if you are migrating a pre-4.3 model to 4.3, it opens up a potential backward compatibilty problem. We have always believed in ensuring that Analytica remain backward compatible as you migrate models forward through new releases, and hence, Analytica 4.3 includes a preference setting called Domain as Self-Index which preserves the old (confused) semantics, and is automatically enabled when you load a pre-4.3 model into 4.3. However, whenever possible, we recommend that you turn off that preference if you can. But, if you have a situation like this, you may encounter the current error as a result of turning off that preference.
How to fix it
To diagnose this, view the result of your variable, «I». If it has a self-index, in most cases you will see its own identifier listed among the pivot controls for its result table. Or, if it a list, it'll display as a list of elements with no named pivoter. If it isn't there, then view the domain attribute for the same variable. If that is not set to a list, then you've found the reason your variable is not a valid index.
If your variable, «I», is a 1-D array, and those values are what you want to use as your index values, it may mean you need to wrap the definition inside an IndexValue function call.
Enable comment auto-refresher