invalid argument when using IF statement on global variable

yesitsmeoffical
yesitsmeoffical Registered Posts: 15 ✭✭✭

Background:

In prepare recipe I created an "if, then, else statement", inside this statement, one of the "then" condition is to set a field to a formula, where this formula itself is another "if statement" that references to a global variable.

Here is the syntax:

Field_A = (formula): if(${global_var} == 1, 'Y','Nxxxxxxx'), where this global_var is currently assigned to an integer value of 0.

Formula is shown as valid inside the "if, then, else statement", however an error message popped out when I tried to save the entire recipe.

Here is the error message:

An invalid argument has been encountered : Incorrect formula: 'if(${global_var} == 1, 'Y','Nxxxxxxx')' : Missing number, string, identifier, regex or parenthesized expression (Parsing error at offset 3), caused by: ParsingException: Missing number, string, identifier, regex or parenthesized expression (Parsing error at offset 3)

Operating system used: win 11


Operating system used: win 11

Answers

  • yesitsmeoffical
    yesitsmeoffical Registered Posts: 15 ✭✭✭

    I also tried double quotes and got the same error.

  • Catalina
    Catalina Dataiker, Dataiku DSS Core Designer, Registered Posts: 135 Dataiker

    Hi,

    The error message appears when the global variable global_var is missing.

    Can you please check if the global variables is correctly set up?

    Your formula works fine when global_var is defined in Administration > Settings > Global variables:

    Screenshot 2023-12-28 at 22.41.24.png

     

    Screenshot 2023-12-28 at 22.30.02.png

     

  • yesitsmeoffical
    yesitsmeoffical Registered Posts: 15 ✭✭✭

    yes the global variable is there otherwise the formula wouldn't be valid.

    I ended up enclosing global_var with double quotes and it worked:

    if("${global_var}" == 1, 'Y','Nxxxxxxx')

Setup Info
    Tags
      Help me…