Jump to content

How to create an instance of DataRelationshipsCalculation Class


Deepak Mathew

Recommended Posts

Hello,

 

I am trying to create an instance ofDataRelationshipsCalculation Class which is inSpotfire.Dxp.Application.Calculations.DataRelationshipsnamespace. But I see that there are no public constructors to get the job done . So how should I correctly make this object.

I am trying to write an ironpython code that can automatically run LinearRegression in Tools > Data Relationships. I saw a similar but inactive post abouit the same subject herehttps://community.spotfire.com/questions/need-create-data-relationships-cal.... But the code snippet suggested here is throwing a lot of errors. I am trying to fix it. Can somebody help.

Link to comment
Share on other sites

Can you try the following script and see if it helps

from Spotfire.Dxp.Application.Calculations.DataRelationships import *

from Spotfire.Dxp.Data import *

from Spotfire.Dxp.Application.Calculations import CalculationTypeIdentifiers

 

#get the collection

drCollection=Document.Calculations

 

#add new relationship to the collection

relationship=drCollection.AddNew(CalculationTypeIdentifiers.DataRelationships)

relationship.SetName("AnovaComparision")

#set the comparison method

relationship.CalculationSettings.ComparisonMethod = ComparisonMethod.Anova;

 

foo = Document.Data.Tables["SalesAndMarketing"].Columns["Rank"];

bar = Document.Data.Tables["SalesAndMarketing"].Columns["Store ID"];

#set the columns

relationship.CalculationSettings.XColumns.Add(foo);

relationship.CalculationSettings.YColumns.Add(bar);

 

relationship.Execute(CalculationExecutionPromptMode.Never)

Link to comment
Share on other sites

  • 4 weeks later...

You can use the AddRange method instead where you can pass multiple columns list as argument,

 

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

 

If you filter on the data table that you apply this DataRelations Tool on, then you should generally see an Refresh icon for the Data Relations visualizations that should recalculate your result

 

datarelation.png

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