How do I use If Then Else for String comparison

lalithanavin
lalithanavin Registered Posts: 3 ✭✭✭✭

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
    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
    edited July 17 Answer ✓

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

Answers

Setup Info
    Tags
      Help me…