Jump to content

Property controls from results of data table


Kinimod24

Recommended Posts

Hello,

I have cross table that has multiple calculated columns controlled by input property controls (highlighted in yellow). It works fine but requires a user to change these to get desired data.

I want these manual inputs to be replaced and controlled by what is in a separate Data Table that I added (image attached) . The fields of this data table should be the property control basically. How can I do this?

 

Property controls.png

Data Table.png

Link to comment
Share on other sites

Hi Kinimod,

Below is an example of pushing a value (in this number of rows from a single data table) into a document property:
 

# Import Class
from Spotfire.Dxp.Data import *

# Set variable for table name
tableName='Data Table'

# Set variable for column name in the table
columnToSearch='Year'

# Assign "Mapping" table as active table
activeTable=Document.Data.Tables[tableName]

# capture marking and set value of "Year" column to CellVal document property

rowIndexSet=Document.ActiveMarkingSelectionReference.GetSelection(Document.Data.Tables[tableName]).AsIndexSet()
if rowIndexSet.IsEmpty !='false':
    CellVal = Document.Data.Tables[tableName].Columns[columnToSearch].RowValues.GetFormattedValue(rowIndexSet.First)

# Pass CellVal and Catval Variable value to document properties

Document.Properties["Year"] = CellVal

In the example above, 'Data Table' is the name of my Data Table. 'Year' is the column I want to push to a document property, called "Year".
When I run this code, the Document Property Year is filled with 2023 (as that was my marked year):
image.png.7257f4f68ec0c0dda6d6eba4dfdadd8b.png

And here is another example you can look at:

Once you have a document property, you can display it in a text area, using a label property control.

Kind regards,

David

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...