Tyler Kendle Posted December 4, 2023 Posted December 4, 2023 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:https://community.spotfire.com/s/article/How-to-sort-a-column-from-a-given-data-table-in-TIBCO-Spotfire-using-IronPython-ScriptingUnfortunately, 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 = AmazonColumn I want to sort = QuantityScript:#Copyright © 2017. TIBCO Software Inc. Licensed under TIBCO BSD-style license.from Spotfire.Dxp.Application.Visuals import TablePlot, TablePlotColumnSortModetable = tableVis.As[TablePlot]() #refers the required table visualization table.SortInfos.Clear() # clears all the existing sorting applied on the tabletable.SortInfos.Add(Document.Data.Tables["Amazon"].Columns["Quantity"], TablePlotColumnSortMode.Descending)#sorts the desired column taken from columnName parameter#Replace the 2nd parameter to sort the column in Ascending order#TablePlotColumnSortMode.AscendingError Message:Traceback (most recent call last): File "<string>", line 5, in <module>NameError: name 'tableVis' is not definedIronPython.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)
Solution Fredrik Rosell Posted December 4, 2023 Solution Posted December 4, 2023 Hello Tyler,The error states that "'tableVis' is not defined". The script expects that you have added tableViz as a script parameter, pointing to your table plot. Have you done that?
Tyler Kendle Posted December 4, 2023 Author Posted December 4, 2023 That was it! I knew I was missing a step but couldn't figure out what it was. Thank you so much!
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