Jump to content
We've recently updated our Privacy Statement, available here. ×

Sort Table With Iron Python

Tyler Kendle
Go to solution Solved by Fredrik Rosell,

Recommended Posts

Hi everyone,

I'm trying to create a Iron Python Script and turn that into a button for my end users to ascend or descend a specific column in a data table.

I am referencing this article:


Unfortunately, my execution has not worked yet. I think I'm missing something obvious but can't figure it out. Hoping someone can spot my mistake.

I have a very simple data table of transactions, below is an example:

Data Table Name = Amazon

Column I want to sort = Quantity


#Copyright © 2017. TIBCO Software Inc. Licensed under TIBCO BSD-style license.

from Spotfire.Dxp.Application.Visuals import TablePlot, TablePlotColumnSortMode

table = tableVis.As[TablePlot]() #refers the required table visualization 

table.SortInfos.Clear() # clears all the existing sorting applied on the table



#sorts the desired column taken from columnName parameter

#Replace the 2nd parameter to sort the column in Ascending order


Error Message:

Traceback (most recent call last):

 File "<string>", line 5, in <module>

NameError: name 'tableVis' is not defined

IronPython.Runtime.UnboundNameException: name 'tableVis' is not defined

  at IronPython.Runtime.Operations.PythonOps.GetVariable(CodeContext context, String name, Boolean isGlobal, Boolean lightThrow)

  at IronPython.Compiler.LookupGlobalInstruction.Run(InterpretedFrame frame)

  at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)

  at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)

  at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)

  at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)

  at Spotfire.Dxp.Application.IronPython27.IronPythonScriptEngine.ExecuteForDebugging(String scriptCode, Dictionary`2 scope, Stream outputStream)

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