Jump to content
  • How to Create a DataRelationships Calculation in Spotfire® Using IronPython Scripting


    This article provides a sample script on how to create a new DataRelationships calculation using IronPython instead of using the UI which can be done as Tools - Data Relationships

    Introduction

    This article provides a sample script on how to create a new DataRelationships calculation using IronPython instead of using the UI which can be done as Tools - Data Relationships

    Code Sample

    # Copyright © 2019. TIBCO Software Inc. Licensed under TIBCO BSD-style license.
    
    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)
     

    References

    License:   TIBCO BSD-Style License

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...