Error Messages/40170

Warning message

When evaluating Subscript, the index Time does not contain the requested value 'a'


You have attempted a subscript operation, which might look like this

X[Time = 'a']

or like this

Subscript(X, Time, 'a')

and the index (Time in the example) does not contain the indicated element.

In many cases, this may indicate an error that you should stop an fix. For example, you might have a spelling mistake, e.g.:

Population[State = 'Caliornia']

or the lower/upper case might not agree (subscript is case sensitive). If this is the case, you should stop evaluation and fix it rather than ignoring warnings.

If you decide to ignore warnings, the result of the evaluation will be Null.

If you decide the logic is correct, and indeed the element is not in the index but that is expected, then the best option is to stop evaluation and change the expression to make this explicit. A good way to do this is to include a «default» with the subscript like this

X[Time = 'a', default: Null]

This syntax also makes it easy to use a default value other than Null. A second way to do it is by surrounding the expression in a call to IgnoreWarnings like this

IgnoreWarnings(X[Time = 'a'])

If you have many of these in the same definition, you can embed the entire definition inside IgnoreWarnings. By using one of these methods to make it explicit that you expect this warning to occur, you will benefit from still being able to see other warnings that might catch other problems, whereas if you ignore warnings you might miss other warnings that might detect other problems that you should fix.

See Also


You are not allowed to post comments.