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

How to sort the list in spotfire using ironpython. Below script help to generate the pages in the dashboard. Requirement is to sort the data with the column name(Primary FE User ID).

farzana khan

Recommended Posts

from Spotfire.Dxp.Data import *

from Spotfire.Dxp.Application.Visuals import *

from Spotfire.Dxp.Data import DataProperty

from Spotfire.Dxp.Data import DataPropertyClass

import Spotfire.Dxp.Application.Filters as filters

import Spotfire.Dxp.Application.Filters.ListBoxFilter

from Spotfire.Dxp.Application.Filters import FilterTypeIdentifiers

import Spotfire.Dxp.Application.PanelCollection

import Spotfire.Dxp.Application.PanelTypeIdentifiers

from Spotfire.Dxp.Application import Panel

from Spotfire.Dxp.Application.Layout import PanelState as ps

from Spotfire.Dxp.Data import DataPropertyClass

from System import String

from System import Array

from Spotfire.Dxp.Data import IndexSet

from Spotfire.Dxp.Data import DataValueCursor

from Spotfire.Dxp.Application.Layout import LayoutDefinition

from System.Collections.Generic import List


myPanel = Document.ActivePageReference.FilterPanel

#get the data table


# Get a reference to the specified filtering scheme on the data table above

dataFilteringSelection = dataFilteringSelection = Document.Data.Filterings["Filtering scheme"]

filteringScheme = Document.FilteringSchemes[dataFilteringSelection]

filterCollection = filteringScheme[table]

# Filtered rows based on the scheme above

filteredRows = filterCollection.FilteredRows

#place generic data cursor on a specific column

cursorA = DataValueCursor.CreateFormatted(table.Columns["Hospital Name & FE ID"])

cursorB = DataValueCursor.CreateFormatted(table.Columns["Primary FE User ID"])

#list object to store retrieved values

valDataA = List [str]();

valDataB = List [str]();

#iterate through table column rows to retrieve the values

for row in table.GetRows(filteredRows,cursorA,cursorB):

#rowIndex = row.Index ##un-comment if you want to fetch the row index into some defined condition

valueA = cursorA.CurrentValue

valueB = cursorB.CurrentValue

if valueA str.Empty:



print valDataA

if valueB str.Empty:



print sorted(valDataB)


rowCount = 0

while rowCount

Link to comment
Share on other sites

You'd want to sort your lists after they are created and before the iterations to create the pages:

In Python the .sort() is used butthat does not work in Spotfires IronPython

mylist = [1, 3, 4, 2]


print(mylist.sort(reverse=True))You would want to utilize sorted() function.

numbers = [1, 3, 4, 2]



print(sorted(numbers,reverse=True))the same works for strings :

numbers = ['d', 'a', 'c', 'b']




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