Search code examples
spotfire

Exporting calculation of all calculated columns


I inherited a couple of reports with several calculated columns. For understanding and documentation I'd need to export all the calculations behind those columns.

Searching the web I couldn't find anything useful.

So far the process is to open properties of each column and manually copy the formula.

Is there something more efficient?


Solution

  • You can use a IronPython script to get each Table Name, Column Name and Expression for calculated columns.

    myDict = {}
    #Loop Through All Data Tables 
    for x in Document.Data.Tables:
        #Loop Through all Columns in Table
        for z in x.Columns:
            #If Column has an Expression /Is Caculated Column 
            if z.Properties.Expression:
                #Append Items to Dictonary to print at end 
                MyItems = {'Table Name' : x.Name , 'Expression' :z.Properties.Expression  }
                myDict[z.Name] = MyItems
                #Print Each Table Name, Column Name and Expression
                print(x.Name , z.Name , z.Properties.Expression)
    #Print Full List 
    print myDict