Making a field equal itself with an if statement?

Calculation for field2:
IIF(field1="G", field2, 0)

So I'm trying to make field2 populate with zero if field1 does not equal G; and if it does, populate with the extracted data. Is this the right way to do it, because it is not working for me?

Answers

  • GrooperGuruGrooperGuru Posts: 456 admin
    I would probably create a new field that represents the final desired value based ultimately on the formula you have posted above.
    Matt Harrison
    Director of Strategy
    [email protected]
  • jclarkjclark Posts: 60 ✭✭✭
    @Aston
    Try setting the calculation expression to:
    If(field1 = "G", field2.ToString , "0")

    And make sure to set the Calculation Mode to:
    Always Set

    Let us know if this is helpful.
  • AstonAston Posts: 12
    @jclark
    This always sets as false for some reason. 
  • jclarkjclark Posts: 60 ✭✭✭
    @Aston
    When you say that it always sets as false are you running field 2 by itself on Test Extraction or are you running the data model level at Test Extraction? If you run at the field level it will always output the false setting "0" because it has no way to run calculation to field 1. I have some screenshots below to show how it was working for me in testing. I did remove the .ToString from the calculation expression as it worked the same with or without it and I thought it would be better to keep it as clean as possible.


    In the top extraction method Field 1 does not = G so the output for Field 2 is 0. In the second extraction method Field 1 is = to G so Field 2 outputs the text pattern it is set for, in this case it is C.
Sign In or Register to comment.

Moderators

GrooperGuru
GrooperGuru
RandoCalrisian
RandoCalrisian
jongoesboom
jongoesboom