Jump to content

Help with a calculated column using IronPython


David Jones 5

Recommended Posts

I have a few document properties that can have values of "Yes" or "No". Let's say they are DocProp1, DocProp2 and DocProp3. They correlate to three columns in my table "Table1", Col1, Col2 and Col3. Iwould like to have a calculated column that concatenates the values in the 3 columns together iftheir respective DocProp is "Yes". So for example,

DocProp1 = "Yes"

DocProp2 = "No"

DocProp3 = "Yes"

My calculated column would be the values from: "Col1 | Col3" (Bonus points if you can add the | as a separator). I've tried to start with this:

 

from Spotfire.Dxp.Data import CalculatedColumn

if Document.Properties["DocProp1"] == "Yes":

Document.Data.Tables["Table1"].Columns["ThisIsACalculatedColumn"].As[CalculatedColumn]().Expression= "([Col1])"

But this only inserts the first column if the doc prop is "Yes". Any help is greatly appreciated.

 

I know this can be done with a standard calculated column, and that's what I currently have. The problem is that the data resets after each doc prop change - and I could have upwards of 12 doc props in the end and I would prefer the user to update everything and then click a button to update the calculated column, instead of it updating after each change.

 

Thanks!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...