Grooper 2.90.0063 is available as of 3-24-2021! Check the  Downloads Discussion  for the release notes and to get the latest version.
Grooper 22.00.0011 is available as of 9-19-2022! Check the  Downloads Discussion  for information on new features, and to download the latest build!
Grooper 21.00.0055 is available as of 9-22-2022! Check the  Downloads Discussion  for the release notes and to get the latest version.

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: 476 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
    Product Manager
    [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: 17
    @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.
  • mounikapotlamounikapotla Posts: 31
    Hi @Aston,
    Did you get the solution for this issue because I am also facing the same.

    Regards,
    Mounika Potla.
Sign In or Register to comment.