Survey banner
Switching to Dataiku - a new area to help users who are transitioning from other tools and diving into Dataiku! CHECK IT OUT

invalid argument when using IF statement on global variable

yesitsmeoffical
Level 3
invalid argument when using IF statement on global variable

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

0 Kudos
3 Replies
yesitsmeoffical
Level 3
Author

I also tried double quotes and got the same error.

0 Kudos
CatalinaS
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
Level 3
Author

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')

0 Kudos