Alteryx Designer Desktop Discussions

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

Problem with If function

saibal_78
8 - Asteroid

Hi all,

 

I have two columns 1) Month 2) Year, both are identified as "Strings", I want to create a new column as "Period" which will have data as "Year" followed by "Month", below is the example of what I want

 

Month = 4, Year = 2018, then Period will be 201804

Month = 10, Year = 2018, Then Period will be 201810

 

I have written below formula which is throwing error as "Invalid type in operator>="

 

Formula I have written : IF [Month]>=10 THEN [Year]+[Month] ELSE [Year]+"0"+[Month] ENDIF

 

Kindly help me to find out the error.

Thanks

3 REPLIES 3
saibal_78
8 - Asteroid

Sorry to bother you, I have identified the error, it is working fine with below

 

IF [Month]>="10" THEN [Year]+[Month] ELSE [Year]+"0"+[Month] ENDIF

 

But I am not getting the result that I wanted, if Month = 4 and Year = 2018 then Period will be 201804 but using above formula I am getting 20184.

 

Nate1
8 - Asteroid

Hi @saibal_78,

 

The issue is because the datatype is a string. If you convert month to a number in the formula you will get the correct results.

 

IF ToNumber([Month])>=10 THEN [Year]+[Month] ELSE [Year]+"0"+[Month] ENDIF

 

saibal_78
8 - Asteroid

Thanks a lot, it's working extremely fine

Labels