Start Free Trial

Alteryx Designer Desktop Discussions

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

If condition is failing

hegdepavithra10
9 - Comet

Hi,

 

I have date converted into string, which is in the format 10-Oct-20. I am trying to extract Oct and 20. I have written a IF condition as below

 

If Length([Date]) = 9 then Substring([Date],3,3) else Substring([Date],2,3) Endif

 

I keep  gettting an error "Unmatched (" in the preview section. I am unable to figure out why the issue is occuring. Could somebody shed some light on to it.

 

Note: I am using a older version of Alteryx hence i do not have DateTime tool. Thats why i had to convert the date from excel into string first inorder to separate the Month and Year from the Date.

4 REPLIES 4
echuong1
Alteryx Alumni (Retired)

Your original formula is valid and works. See below.

 

I suggest trying to use left and right formulas to grab both pieces.

 

echuong1_0-1603389647911.png

 

You can also use regex to consolidate more.

 

echuong1_0-1603389787540.png

 

 

David-Carnes
12 - Quasar

@hegdepavithra10 

I'm a big fan of IIF

iif(Length([Date]) = 9, Substring([Date], 3, 3), Substring([Date], 2, 3))

 

 

Good luck!
David

 

 

David-Carnes
12 - Quasar

You could also just use the Text to Columns tool with the dash as the delimiter.

 

RobertOdera
13 - Pulsar

Hi, @hegdepavithra10 

 

Is it possible that you have a duplicate white space somewhere?

Try this, adding Trim, and see if your result is improved.

 

If Length(Trim([Date])) = 9 then Substring(Trim([Date]),3,3) else Substring(Trim([Date]),2,3) Endif

 

Cheers!

Labels
Top Solution Authors