Join the Inspire AMA with Joshua Burkhow, March 31-April 4. Ask, share, and connect with the Alteryx community!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

IsInteger and leading Zeros

kevind0718
7 - Meteor

Hello:

 

I have a hard time believing what I am seeing here.  

I am using IsInteger to determine if a string is an integer (is a zip code).

What I found is that IsInteger gets confused by leading zeroes.

 

Attached is  simple workflow.

 

Here are my results

Field1 Check
20220228   True
20200331   True
20270220   True
20161001   True
00112233   False
001234       False
010101       False

 

 

What am I missing here.

 

Best Regards

 

KD

11 REPLIES 11
aatalai
14 - Magnetar

@kevind0718 check this workflow

kevind0718
7 - Meteor

add some text strings to the Text Input  you then get 

 

Field1          Check
20220228    True
20200331    True
20270220    True
20161001    True
00112233    True
001234        True
010101        True
ABC             True
ALTERYX     True

 

plus some warnings

The issue is:  we have a string want to check if that string contains only digits (0 -9)

      And there could be leading zeros

 

KD

 

Deano478
12 - Quasar

hey @kevind0718 try this in your formula is worked jut now for me when I tested out my Code:

 

IF ISNULL([Field1]) THEN
    0
ELSEIF REGEX_Match([Field1], "^[0-9]+$") THEN
    1
ELSE
    0
ENDIF
kevind0718
7 - Meteor

Does not answer the question:  Is there an issue with IsInteger? 

Maybe a bug

 

KD

kevind0718
7 - Meteor

And I found a regex work around.  

Thanks for the suggestion.

Raj
16 - Nebula

@kevind0718 
is this solved or still working on the issue?

if solved mark your solution done and close the question.

kevind0718
7 - Meteor

Not resolved

 

The issue is:  we have a string,  want to check if that string contains only digits (0 -9)

      And there could be leading zeros

 

IsInteger seems to fail when there are leading zeroes in the string.

Bug?

RaphaelSilva
9 - Comet

Not exactly a bug, leading zeros are useless, numerically speaking, so if that contains a leading zero it is not an integer, it is a string.
In the same way a ZIP code is not a integer per say, it is a string with numbers.

Deano478
12 - Quasar

@kevind0718 no its not a bug it is the way Alteryx interprets the values this stems from most programming languages as leading zero's can imply different number representation/formats such as octal or hexadecimal to name a few depending on the context hence why alteryx is most likely treating the leading zero's as text to avoid these types of issues and for simplicity purposes.

Labels
Top Solution Authors