Jump to content
  • How to Manage Data Table Relations in Spotfire® Using IronPython Scripting


    It is possible to manage data table relations in your analysis file with the API using IronPython scripting. This allows you to add new relations, read relations on a given table, or remove relations.

    Introduction

    It is possible to manage data table relations in your analysis file with the API using IronPython scripting. This allows you to add new relations, read relations on a given table, or remove relations.

    Example

    from Spotfire.Dxp.Data import *
    
    ##Define the 2 tables to be used
    table1=Document.Data.Tables["Table1"]
    table2=Document.Data.Tables["Table2"]
    
    dm=Application.GetService(DataManager)
    
    ## (1) Add data table relation
    ## Note: '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 next 1 line if required
    #existingRelations=dm.Relations.FindRelations(table1)
    
    ## (3) Delete Relations for the specified tables, uncomment next 3 lines if required
    #existingRelations=dm.Relations.FindRelations(table1,table2)
    #for exRel in existingRelations:
    	#dm.Relations.Remove(exRel)
     

    References

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...