Customer Banners (Ads) - SpiceUp. AX and SpotfireX Disclaimer



If you find this site useful and you want to support, buy me a coffee   to keep this site alive and without ads.

GetDistinctRows (7.0+)

#get unique values from column (7.0)
from Spotfire.Dxp.Data import DataValueCursor
from Spotfire.Dxp.Data import IndexSet

tableName = 'MyDataTable'
columnName = 'MycolumnName'

dt = Document.Data.Tables[tableName]
cursor = DataValueCursor.Create[str](dt.Columns[columnName])
distinctRows = dt.GetDistinctRows(None,cursor) #none param to grab them by the all
#distinctRows = dt.GetDistinctRows(IndexSet(dt.RowCount,True),cursor) #...or an index set with all true to get them all.

#get uniques
vals = []
distinctRows.Reset()
while distinctRows.MoveNext():vals.append(cursor.CurrentValue)

#show results
print vals

2 comments:

Unknown said...

Hi,

How do i use these values in the text area?

Jose Leviaguirre said...

Vedanshi,

Instead of printing the output, store it in a document property:

Document.Properties["dVals"] = vals

Make sure you created a String doc prop in Spotfire called 'dVals'

In the text area use a label control to point to dVals