Jump to content

Need to create data relationships calculation using ironpython

Namit Gaur

Recommended Posts

Here is an example script to add/remove data table relations:


from Spotfire.Dxp.Data import *


##Define the 2 tables to be used






## (1) Add data table relation

##Id & Name are the names of the columns available in the 2 tables

dm.Relations.Add(table1, table2, '[Table1].[id]=[Table2].[id] and [Table1].[Name]=[Table2].[Name]')


## (2) Get All Relations for the specified table, uncomment if required



## (3) Delete Relations for the specified tables, uncomment if required


#for exRel in existingRelations:


Link to comment
Share on other sites

Thanks for the response Sean, but what I needed was an ironpython script to creata a data relationships tool which gives linear regression calculation and correlation between two sets of columns. We do it manually by using the option Tools->Data Relationships but I need it to automate it using script.
Link to comment
Share on other sites

Here is an example of adding a linear regression like via Tools > Data Relationships:

In this case we have a table named "cars" with a column "Sold" and a calculated column "[sold]*3" which are used when creating the table "Data Relationships".


DataRelationshipsCalculation relationships = app.Document.Calculations.AddNewDataRelationshipsCalculation();

relationships.CalculationSettings.ComparisonMethod = ComparisonMethod.LinearRegression;


DataColumn foo = app.Document.Data.Tables["cars"].Columns["Sold"];

DataColumn bar = app.Document.Data.Tables["cars"].Columns["[sold]*3"];






API Reference:https://docs.tibco.com/pub/doc_remote/sfire_dev/area/doc/api/TIB_sfire-analyst_api/topic=html/N_Spotfire_Dxp_Application_Calculations_DataRelationships.htm

Link to comment
Share on other sites

  • 2 years later...

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