community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
New Data Science Blog

Check out the latest post: All Models Are Wrong

READ MORE
Announcement | We'll be doing maintenance between pm 4- 6pm MT, which may impact your experience. Thanks for your patience as we work on improving the community!
SOLVED

Leading 0's in formula

Highlighted
Meteor

I'm creating a formula where my posting period is between 1-9 then I want it to be given a leading 0. I have created the following formula but I am getting the error "Invalid type in operator >="

Can someone help me fix the below formula? Thank you

 

IF [Posting Period]>=1 AND [Posting Period]<=9
THEN "0"+[Posting Period]
ELSE [Posting Period]
ENDIF

Alteryx
Alteryx

The Invalid operator is due to trying to find a numeric calculation on a String.  You can use the ToNumber() function to help with this.

 

IF tonumber([Posting Period])>=1 AND tonumber([Posting Period])<=9
THEN "0"+[Posting Period]
ELSE [Posting Period]
ENDIF

 

See attached.

Scott Jones
Strategic Sales Engineer
Alteryx, Inc.
Alteryx Certified Partner

Hey @AustinBauer

 

Your [Posting Period] is a string...so wrap the first part in ToNumber()

 

So if ToNumber([Posting Period]) >= 1 AND toNumber([Posting Period])<=9 etc...

Labels