Writing an if statement to check if a value is not contained in an array

7mxd
7mxd Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Registered Posts: 13

Hey everyone!

Currently I am using the prepare recipe, and specifically the Create if, then, else statements processor. For one of the if statements, I want to write an if statement that check if each value in a specific column is not contained in a given array. I know that I can compare a value with another value; however, I would like to compare a value with an array of values (string in this case).

Is there any way to do that?

Best regards,
Ahmed

Best Answer

Answers

  • 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

    @7mxd

    I’m not clear that this can be done using the create, if, then else visual prepare recipe step. I am wondering if you can use the formula recipe step to get what you want done.

    here is a post that seems to be related to your use case

    https://community.dataiku.com/t5/General-Discussion/Dataiku-formula-language-for-SQL-IN/m-p/16270/highlight/true

    If you want to use the create, if then else step for other reasons you might simply use the formula step to create a temporary Boolean column with the answer if you found or did not fine that item you were looking for. Then in the create if then else column you would simply reference the temporary column you created.

  • MayeulR
    MayeulR Dataiker Posts: 11 Dataiker

    Hello,

    You can achieve this with the Create...If..then processor by using the operator "is none of the strings".

    Best,

  • 7mxd
    7mxd Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Registered Posts: 13

    That's clear Alex! Thank you! Appreciate your help!

  • 7mxd
    7mxd Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Registered Posts: 13

    I am already using the formula processor; however, I thought that the if, then, else processor might give a more accurate result.

    Thank you so much for your response. I appreciate your help!

Setup Info
    Tags
      Help me…