0

I need to build an expression through which to achieve a rule-based classification by multiple fields. The basic expression could be: "Field 1" = 'Value a' AND "Field 2" = 'Value b' AND "Field 3" = 'Value c' but I need to be able to write in the same rule n expression with the same structure but referring to different values of the same fields, ie enter image description here

so that each class is composed of the set of elements (features) that satisfy the conditions of the single basic expression. As a second possibility to obtain the same classification I considered the possibility of creating a new column whose values are obtained through a CASE WHEN / THEN expression that contains the same expressions described above, ie: enter image description here

Can both be correct ways to solve the problem and what can be the correct syntax?

  • 1
    did you try to combine different combinations with 'OR'. So: ("Field 1" = 'Value a' AND "Field 2" = 'Value b' AND "Field 3" = 'Value c') OR ("Field 1" = 'Value x' AND "Field 2" = 'Value y' AND "Field 3" = 'Value z') ? – PieterB Jul 5 '18 at 9:04
  • Not yet, thanks. I would like to ask: in this way will all the values that satisfy each expression be included in the classification? in this case is the use of brackets correct? – Andrew-63 Jul 5 '18 at 9:49
  • it al depends on the logic you want to use. In my example the result between the brackets will be evaluated one by one. It is a combination of the 3 fields in the brackets that will be evaluated. – PieterB Jul 5 '18 at 10:01
  • Your hint has solved the problem perfectly ... it seems to work very well! (I'm testing on different layers) thanks a lot! – Andrew-63 Jul 6 '18 at 9:19
  • OK, I'll post it as an answer – PieterB Jul 6 '18 at 10:37
0

You have to to combine the different combinations with 'OR'.

So: ("Field 1" = 'Value a' AND "Field 2" = 'Value b' AND "Field 3" = 'Value c') OR ("Field 1" = 'Value x' AND "Field 2" = 'Value y' AND "Field 3" = 'Value z')

The combination of the 3 fields within the brackets will be evaluated one by one.

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.