Leonard Scriven Posted December 19, 2019 Posted December 19, 2019 I found this script andit works well, but I need to use it for a REAL instead of a string # Copyright 2017. TIBCO Software Inc. Licensed under TIBCO BSD-style license. from System import Array from Spotfire.Dxp.Data import IndexSet from Spotfire.Dxp.Data import DataValueCursor # Get table tbl= Document.Data.Tables["Users"] # Get access to the Column populating the choice values # of the drop-down list control choicesCol = tbl.Columns["AccountTypeCode"] rowCount = tbl.RowCount rowsToInclude = IndexSet(rowCount,True) # Create a cursor to the Column we wish to get the values from cursor1 = DataValueCursor.CreateFormatted(choicesCol) # Create Array object that will hold values strArray = Array.CreateInstance(str,rowCount) # Loop through all rows, retrieve value for specific column, # and add value into array for row in tbl.GetRows(rowsToInclude,cursor1): rowIndex = row.Index value1 = cursor1.CurrentValue strArray[rowIndex-1] = value1 # Get only unique Values, cast to a list uniqueVal = list(set(strArray)) # Order list uniqueVal.sort() # Set document property to first value found in the list Document.Properties["AccountType"] = uniqueVal[0] How do I adjust it to use a REAL instead of STRING
Tyger Guzman 2 Posted December 20, 2019 Posted December 20, 2019 You can force the value into a float. I tested with the document property being a input field and also a drop down (Numercial Range & Unique Values from Column ). from System import Array from Spotfire.Dxp.Data import IndexSet from Spotfire.Dxp.Data import DataValueCursor # Get table tbl= Document.Data.Tables["Table"] # Get access to the Column populating the choice values # of the drop-down list control choicesCol = tbl.Columns['Column'] rowCount = tbl.RowCount rowsToInclude = IndexSet(rowCount,True) # Create a cursor to the Column we wish to get the values from cursor1 = DataValueCursor.CreateFormatted(choicesCol) # Create Array object that will hold values strArray = Array.CreateInstance(str,rowCount) # Loop through all rows, retrieve value for specific column, # and add value into array for row in tbl.GetRows(rowsToInclude,cursor1): rowIndex = row.Index value1 = cursor1.CurrentValue strArray[rowIndex-1] = value1 # Get only unique Values, cast to a list uniqueVal = list(set(strArray)) # Order list uniqueVal.sort() # Set document property to first value found in the list Document.Properties["Number"] = float(uniqueVal[0]) -2
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