Expression is invalid with the error "The expression is too complex."

Expression is invalid with the error "The expression is too complex."

book

Article ID: KB0079787

calendar_today

Updated On:

Products Versions
Spotfire Analyst All Versions

Description

In the custom expression dialog window, the red exclamation point (!) error icon is displayed with the alt-text "The expression is too complex" for a new expression or an expression that was working in an earlier Spotfire version.

Symptoms:
When entering an expression (for a calculated column, axis custom expression, etc.), the red exclamation point error icon (!) is displayed in the custom expression dialog window, with the alt-text "The expression is too complex." This can also be seen after an upgrade to Spotfire version 6.5 or later, for an expression that was valid in the earlier version of Spotfire. The error means the expression is not valid and cannot be run. The dialog's OK button is also disabled so that the expression cannot be saved.

Cause:
Expression complexity limits were introduced in Spotfire 6.5.0 HF-001 to help prevent stack overflow errors. These complexity-limit settings were also back-ported to earlier versions, but the limits were set to infinity so there would be no changes in the default behavior. The new settings were introduced in the following Spotfire client hotfixes and also exist in later hotfixes and newer versions.
  • TS 6.5.0 HF-001 - Limit defined
  • TS 6.0.1 HF-006 - No limit defined by default, parameter set to infinity
  • TS 5.5.1 HF-010 - No limit defined by default, parameter set to infinity
  • TS 5.0.2 HF-017 - No limit defined by default, parameter set to infinity

In Spotfire 6.5.0 HF-001 and later, the default values for these limits are as follows:
  • 4000 for the depth of nested functions as defined by the ExpressionParser_MaxNestingDepth setting. For example, nested functions cannot have a depth of 4000 or greater: An expression such as "If(If(If(If(...),3),2),1)" would fail if the number of recursive If() functions continued to 4000 or greater.
  • 400 for the maximum tree height as defined by the ExpressionParser_MaxTreeHeight. For example, the number of operations that are allowed: An expression like "1 + 2 + 3 + 4.... + 400 + 401" would fail because it exceeded the height limit of 400.

Issue/Introduction

Expression is invalid with the error "The expression is too complex."

Resolution

These limits should not be changed since they were explicitly created and defined with these values to avoid exceptions and prevent instability. It is not a supported scenario if these limits are modified, but technically they can be adjusted for testing purposes. These settings can be adjusted by explicitly adding the corresponding nodes to the Spotfire.Dxp.Main.dll.config file, which is located here:
  •     ...\TIBCO\Spotfire\X.X.X\Modules\Spotfire DXP Forms_XXXXXX\Spotfire.Dxp.Main.dll.config
 
Within the <applicationSettings> node, add a <Spotfire.Dxp.Data.Properties.Settings> node like the following:

<applicationSettings>
...
<Spotfire.Dxp.Data.Properties.Settings>
    <setting name="ExpressionParser_MaxNestingDepth" serializeAs="String">
        <value>4000</value>
    </setting>
    <setting name="ExpressionParser_MaxTreeHeight" serializeAs="String">
        <value>400</value>
    </setting>
</Spotfire.Dxp.Data.Properties.Settings>
...
</applicationSettings>


This will make it possible to replace the default values of 4000 and 400 for these settings with other values.  


Warning: Increasing these limits is not a supported scenario. 
 
Warning: Increasing these limits may lead to stability issues. These include, but are not limited to, stack overflow errors.