Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
datanibbler
Champion

ISNUM in script returns FALSE while on the GUI, it's TRUE?


Hi,

I have a line like this in my script

>> LET v_Trace = IF(ISNUM([field]) = -1, 'yes', 'no') <<

Strangely, this returns "no" in the script while on the GUI the same function, applied at the same stage of execution, returns 'yes'.

Can somebody explain this difference to me?

Thanks a lot!

Best regards,

DataNibbler

1 Solution

Accepted Solutions
tresesco
MVP

Manish Kachhia

Consider below example... This will return as no because not all the values of field is Numeric.

Data:

Load * Inline

[

  field

  123

  ABC

  DEF

  456

];

LET v_Trace = IF(ISNUM([field]) = -1, 'yes', 'no');

TRACE $(v_Trace);

because, if you pass field name in isnum() outside load and without any field value position  - it actually returns a NULL. And null is not numeric. hope that makes sense.

View solution in original post

7 Replies
MK_QSL
MVP

Consider below example... This will return as no because not all the values of field is Numeric.

Data:

Load * Inline

[

  field

  123

  ABC

  DEF

  456

];

LET v_Trace = IF(ISNUM([field]) = -1, 'yes', 'no');

TRACE $(v_Trace);

datanibbler
Champion
Author

Hi Manish,

this seems logical, the variable considers the entire table, about 250.000 records and if one of them is not numeric, it will turn to 'no'.

But in my instance, ALL the values are numeric - if I try it with a new listbox_object on the GUI, I have the two values -1 and 0, but I cannot select 0.

MK_QSL
MVP

Can you share sample file only having this field? also provide how your are using in UI !

jonathandienst
Partner - Champion III

In the script, [field] has no value, so IsNum correctly returns False return. In the front end, [field] may contain a single value, and could return True.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
tresesco
MVP

Manish Kachhia

Consider below example... This will return as no because not all the values of field is Numeric.

Data:

Load * Inline

[

  field

  123

  ABC

  DEF

  456

];

LET v_Trace = IF(ISNUM([field]) = -1, 'yes', 'no');

TRACE $(v_Trace);

because, if you pass field name in isnum() outside load and without any field value position  - it actually returns a NULL. And null is not numeric. hope that makes sense.

datanibbler
Champion
Author

Hi Manish,

that would be somewhat difficult as there is a lot of sensitive data that I'm processing here - and there are a lot of fields - and that field which I want to check has actually already been processed because I get it from Excel and the settings rgd. the decimal_separator are wrong, so I switch it around. I think I remember there was also this "it works for everyone else, so i cannot show how it does not work" effect when I first asked about this here ...

The expression in the script is (copied)

LET v_Trace = 'Gesamtzeit ist numerisch: ' & IF(ISNUM(Gesamtzeit_gerundet_syncreon)= (-1), 'ja', 'nein');
TRACE $(v_Trace);
LET v_Trace = 'Umsatz ist numerisch: ' & IF(ISNUM(Kosten_gerechnet_nach_gerundeten_Zeiten)= (-1), 'ja', 'nein');
TRACE $(v_Trace);
LET v_Trace = NULL();

The expression I use on the GUI is

ISNUM(Gesamtzeit_gerundet_syncreon)

and

ISNUM(Kosten_gerechnet_nach_gerundeten_Zeiten)

Best regards,

DataNibbler

datanibbler
Champion
Author

Hi tresesco,

sure that makes sense. So I will delete that code as it potentially leads to some confusion.

Thanks a lot!