Michael Daiy Posted January 16, 2019 Share Posted January 16, 2019 I am programatically determining the maximum value of a particular column. I need to get a corresponding value in the same rowfroma different column. How can I go about doing this using IronPython Link to comment Share on other sites More sharing options...
Raghav . Posted January 16, 2019 Share Posted January 16, 2019 Hello, Just to understand the question better. You did a max(column1) and then Max(column2) and you want to calculate max(max(column1),max(column2)) if you add a screenshot what you want to achieve, would be great to see Regards Raghav Link to comment Share on other sites More sharing options...
Michael Daiy Posted January 16, 2019 Author Share Posted January 16, 2019 Hello, I have attached an example to help us communicate a little better. I used GetMaxValue() on Column B. This would return 9. The value in column A that I am looking to assign to a variable would be 1. Same row as the maximum value of B. Link to comment Share on other sites More sharing options...
Michael Daiy Posted January 16, 2019 Author Share Posted January 16, 2019 example Link to comment Share on other sites More sharing options...
Raghav . Posted January 16, 2019 Share Posted January 16, 2019 ok, The way i would approach is because programmatically. 1.Get max(B)=9, 2.Identify the rowid of this max value ,i.e. 5 3.Print rowid=5 for column A i.e."corres_col"= 1 This is the logic i can think off. Link to comment Share on other sites More sharing options...
Raghav . Posted January 16, 2019 Share Posted January 16, 2019 forgot Screen shot showing the logic, the last col is the max(corresponding_colA) Link to comment Share on other sites More sharing options...
Michael Daiy Posted January 16, 2019 Author Share Posted January 16, 2019 Thanks for your advice! However I am looking for a solution in ironpython as adding in calculated columns would not work with what I am doing Link to comment Share on other sites More sharing options...
Matthew Stahl Posted January 17, 2019 Share Posted January 17, 2019 Hopefully the script shown in the screenshot will be of use. If the max value for a column is known, DataTable.Select(expression) will return a RowSelection that can be used to get the value(s) from another row. Note that multiple rows may be returned by the Select if multiple rows of "Column B" contain the maximum value. 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