How do I use If Then Else for String comparison

Solved!
lalithanavin
Level 1
How do I use If Then Else for String comparison

Hi 

 

I have the following expression to be used to populate a column in DataIKU, am not sure how this can be used

 

If IsNotNull(ACCTUNIT) Then ACCTUNIT Else If IsNotNull(GLBU) Then GLBU Else If IsNotNull(BU_AIR) Then BU_AIR Else If IsNotNull(BU_AIP) Then BU_AIP Else If IsNotNull(CTY) Then CTY Else "xxx"

 

If (COUNTRY_CODE=='SG','yyyyy','xxxxx')

0 Kudos
1 Solution
tgb417

@lalithanavin 

Unlike MS Excel, the formula functions are case sensitive.  If (upper case I) should be if (lower case I).  If (upper case I) will cause an error.

Otherwise, I tested the following and it worked as expected.

if(Title=='To Big','True','False')

Note that the Column name Title is also case sensitive. 

The string 'To Big' in my example above, needs to be an exact match both on the case of the letters in the string in your data and any pre or post spaces.

You may find that you want to also use the trim (string s) and toLowercase (string s) to increase your likeliness to match if you have sort of dirty data.

Hope that helps.

--Tom

View solution in original post

0 Kudos
3 Replies
dima_naboka
Dataiker

Hi, please use nested IF() expression to comply to formula function spec

if(isNotNull(gender),gender,if(isNotNull(customerID),customerID,'empty_customerID_gender'))

 Screenshot 2020-08-27 at 14.05.19.png

lalithanavin
Level 1
Author

Is there any problem with this syntax?

If (COUNTRY_CODE=='SG','yyyyy','xxxxx')

 
0 Kudos
tgb417

@lalithanavin 

Unlike MS Excel, the formula functions are case sensitive.  If (upper case I) should be if (lower case I).  If (upper case I) will cause an error.

Otherwise, I tested the following and it worked as expected.

if(Title=='To Big','True','False')

Note that the Column name Title is also case sensitive. 

The string 'To Big' in my example above, needs to be an exact match both on the case of the letters in the string in your data and any pre or post spaces.

You may find that you want to also use the trim (string s) and toLowercase (string s) to increase your likeliness to match if you have sort of dirty data.

Hope that helps.

--Tom
0 Kudos