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')
Best Answer
-
tgb417 Dataiku DSS Core Designer, Dataiku DSS & SQL, Dataiku DSS ML Practitioner, Dataiku DSS Core Concepts, Neuron 2020, Neuron, Registered, Dataiku Frontrunner Awards 2021 Finalist, Neuron 2021, Neuron 2022, Frontrunner 2022 Finalist, Frontrunner 2022 Winner, Dataiku Frontrunner Awards 2021 Participant, Frontrunner 2022 Participant, Neuron 2023 Posts: 1,598 Neuron
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.
Answers
-
dima_naboka Dataiker, Dataiku DSS Core Designer, Dataiku DSS & SQL, Dataiku DSS Core Concepts Posts: 28 Dataiker
Hi, please use nested IF() expression to comply to formula function spec
if(isNotNull(gender),gender,if(isNotNull(customerID),customerID,'empty_customerID_gender'))
-
Is there any problem with this syntax?
If (COUNTRY_CODE=='SG','yyyyy','xxxxx')