Deepak Mathew Posted December 21, 2020 Share Posted December 21, 2020 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 More sharing options...
Shandilya Peddi Posted December 21, 2020 Share Posted December 21, 2020 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 More sharing options...
Deepak Mathew Posted December 22, 2020 Author Share Posted December 22, 2020 Hello Shandilya, This works. But I have two more question. 1.How to add multiple columns in X and Y columns Should it be done using a for loop) 2.Is there anyway to do it on a filtered version of an existing table Deepak Link to comment Share on other sites More sharing options...
Deepak Mathew Posted January 19, 2021 Author Share Posted January 19, 2021 Hello can any body help me understand how to add the above mentioned 2 features in to the code above. It would be of great help. Link to comment Share on other sites More sharing options...
Shandilya Peddi Posted January 20, 2021 Share Posted January 20, 2021 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 Link to comment Share on other sites More sharing options...
Deepak Mathew Posted January 25, 2021 Author Share Posted January 25, 2021 Thanks Shandilya AddRange Works once we "Add" each column as element of collection of type List[DataColumn]() Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now