Product: TIBCO Spotfire®
Calculated Columns become invalid after renaming the columns used in the expression in TIBCO Spotfire
Lets say you have a calculated column with expression like below:
Now if you rename the column from "Column1" to "Column3" then this would result in the above calculated column becoming invalid (since [Column1] no longer exists but it is present in the express).
The issue here is that the expression uses the PreProcessor ($) syntax and in these cases the expression cannot be automatically updated.
The general workflow in case of renaming a column is that the expression is parsed into a syntax tree first and then the content that represents the columns is found and they are updated. Later the syntax tree is formatted back to a string. Whereas if you are using the PreProcessor ($) syntax, this preprocessor is a step that happens before the parsing and is a simple "string to string" transformation. When formatting back the syntax tree to a string, the only thing you'd get back is the string as it looked after preprocessing. E.g. the $-content would be lost.
Instead of using the PreProcessor syntax, if you use the DocumentProperty method then upon renaming of any column the expression is automatically updated with the new name. For example the expression above can be rewritten using the DocumentProperty() syntax instead of the PreProcessor $ syntax:
In some situations the expression can be written in both ways but in some advanced cases the expression can be built only using the Preprocessor syntax. The preprocessor can be used to write expressions that are hard or impossible to write without it, that is why it is commonly used. In these cases the expression should be manually updated with the new column name. Doc: Properties in Expressions