Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
ALTER.NEXT:

Join us on Dec 2 for a half-day virtual analytics + data science event!
US & CA customers only

SAVE YOUR SPOT
It's the most wonderful time of the year - Santalytics 2020 is here! This year, Santa's workshop needs the help of the Alteryx Community to help get back on track, so head over to the Group Hub for all the info to get started!
SOLVED

Leading 0's in formula

Highlighted
7 - 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.
Highlighted
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