I am trying to find the logic for the below scenario. I have a page list which has results as attached. I am trying to find the maximum id within the department in an activity. I need your help in building this logic.
Why can't you try this requirement with the Report definition rather than activity, so that in report definition you can group the results by Department property and then perform the sort on ID so that you can get the maximum ID record on top of each department group list. If you have any other criteria for the usage of the activity then we can think of how to achieve this in activity.