1

I've been trying to search for a solution for this to no avail.

I have a value relation set up and want another field connected and relative to this.

Example: Field 1 (Value 1) Field 2 (Value 2)

Value 1.1 = Value 2.1 Value 1.2 = Value 2.2 And so on.

So if i add Value 1.1 to field 1 i want it to automatically add Value 2.1 to field 2.

Field 2 does not need to be editable so it only needs to go one way so to speak.

Is there a solution for this?

EDIT: Clarification what i want to do. The actual values i want to use are tree species names. If "Acer platanoides" is added to field 1 i want "Maple" in field 2. I have a value relation set up with the species name but want the common name to be added automatically as well. Preferably in a separate field.

6
  • Could you please edit your question with the software you are using?
    – gHupf
    Apr 26, 2023 at 11:40
  • Of course, sorry about that! Done!
    – Niklas
    Apr 27, 2023 at 5:21
  • Your question lacks details, but it sounds like you could make use of a virtual field
    – Matt
    Apr 27, 2023 at 5:53
  • Are Field 1 & Field 2 numeric fields? Otherwise, @Cushen's proposed code for the virtual field won't work.
    – jpinilla
    Apr 27, 2023 at 10:47
  • No, the fields are not numeric values im afraid. I chose to use value wording because i thought it would make it more understandable, but maybe i just made it confusing. I will update my question with clarification!
    – Niklas
    Apr 28, 2023 at 6:50

1 Answer 1

2

We can use a Virtual Field to do this. Create Field 2 as a virtual field and with an expression.
In the 'Maple' example above we want to turn a string into another based on the Field1 value. For this we can use a CASE Expression such as:

CASE 
WHEN "FIELD1" = 'Acer platanoides' THEN 'Maple'
WHEN "FIELD1" = 'Quercus alba' THEN 'White Oak'
END

As values are added or edited to Field1 Field2 will update once a save is made. We can add as many WHEN checks to the CASE as we need.

In my example below Field1 has the name 'HubDist' & we are dealing with numbers not strings

example image

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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