2

I have an Attribute table similar to the one in my example Picture, just with thousdands of objects.

enter image description here

Some of the objects have the same value in "field 1" but different values in field 2. I want to write an expression that finds all objects with same values in field 1, among them compares the values in field 2 and memorizes the highest value and finally gives all the selected objects this highest value in field 3.

The expression should do 3 things. 1. the expression selects all objects with same values in field 1. For example in my image it selects the last object, the second last object and the object exactly in the middle.

  1. It checks for the highest value in field 2 among them.

  2. It gives all 3 objects the highest field 2 value in field 3.

Would that be possible?

2

The aggregate function maximum returns the maximum value from a field or expression. Optional parameters can be included to group equal values from a field which would apply in your case:

maximum(expression[,group_by][,filter])

So you could use something like the following:

maximum( "field 2", "field 1" )
  • 1. the expression selects all objects with same values in field 1. For example in my image select the last object, the second last object and the object exactly in the middle. 2. it checks for the highest value in field 2 among them. 3. It gives all 3 objects the highest field 2 value in field 3. – Dennis Jan Jul 2 at 11:42
  • 1
    This function does exactly that. – Erik Jul 2 at 11:44
  • Oh wow ok you are right, sorry. I thought it would compare the values of field 2 and field 1 of every object and add the higher one in field 3. Thanks for the help! – Dennis Jan Jul 2 at 11:51
  • @DennisJan - No problem and most welcome, glad it helped :) – Joseph Jul 2 at 11:57
  • Could you help me with the next step as well. I have now at field 3 some random values and a empty field 4. a) I want to select all objects with equal values in field 1 b) Among them select the object with the highest value in field 2 c) Take the value in field 3 of that object. d) Add that value to field 4 for all object selected after step a). I that possible? – Dennis Jan Jul 2 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.