Sean Conroy Posted March 9, 2020 Share Posted March 9, 2020 I know how to get the filtered rows of a column in IronPython: myTable = Document.Data.Tables["Table"] dataFilteringSelection = Document.Data.Filterings["Filter"] filteringScheme = Document.FilteringSchemes[dataFilteringSelection] filterCollection = filteringScheme[myTable] filteredRows = filterCollection.FilteredRows myCursor = DataValueCursor.CreateFormatted(myTable.Columns["myColumn"]) # Iterate over the filtered rows for row in Reference.GetRows(filteredRows,myCursor): val = float(myCursor.CurrentValue) if val > maxVal: maxVal = val And I know how to get the min and max of a column using IronPython: min = myTable.Columns['myColumn'].RowValues.GetMinValue().Value max = myTable.Columns['myColumn'].RowValues.GetMaxValue().ValueBut is there a way to get thefilteredmin and max values from the column, without having to iterate through the column, comparing each value against the current min / max This is very slow for large tables, and I'm trying to adjust visualization properties, but this will bother the user. Link to comment Share on other sites More sharing options...
Tyger Guzman 2 Posted March 9, 2020 Share Posted March 9, 2020 Use a python script to get the min and max values from thefilter : #get list of filtered rows dt = Document.ActiveDataTableReference #This line implements the current filtering rows = Document.ActiveFilteringSelectionReference.GetSelection(dt).AsIndexSet() #get min and max values from the set min = dt.Columns["column1"].RowValues.GetFormattedValue(rows.First) max = dt.Columns["column1"].RowValues.GetFormattedValue(rows.Last) print(min) print(max) https://spotfired.blogspot.com/2014/07/get-min-and-max-values-from-range-filter.html Link to comment Share on other sites More sharing options...
Sean Conroy Posted March 9, 2020 Author Share Posted March 9, 2020 This is great - but it references the First and Last values in the table. What if the table is not sorted by this column Any way to change get the min and max Link to comment Share on other sites More sharing options...
Tyger Guzman 2 Posted March 9, 2020 Share Posted March 9, 2020 It's reference the first and last values in the filter which are sorted so the order of the data table is irrelevant. Link to comment Share on other sites More sharing options...
Sean Conroy Posted March 9, 2020 Author Share Posted March 9, 2020 myTable = Document.Data.Tables["myTable"] rows = Document.Data.Filterings["My Filter"].GetSelection(myTable).AsIndexSet() min = myTable.Columns['myColumn'].RowValues.GetMinNumericValue(rows) max = myTable.Columns['myColumn'].RowValues.GetMaxNumericValue(rows)This is what worked for me, based on the answer above with a few adjustments. Link to comment Share on other sites More sharing options...
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