Public

How to write this formula in dataiku ?

Registered Posts: 17

IF [ASIA]=0 THEN "CERO"
ELSEIF [ASIA]<=1 THEN
IF [ASIA]>=-1 THEN "DENTRLRANCIA"
ELSEIF [ASIA]>0 THEN "DIFERETIVA"
ELSE "DIFERENTIVA" ENDIF
ELSEIF [TOTAL]=0 THEN "DIOT"
ELSEIF [TOTAL_CONTABLE]=0 THEN "CONTABLE"
ELSEIF [ASIA]>0 THEN "DIFER POSI"
ELSE "DIFERNEGVA" ENDIF

• Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,211 Dataiker
edited July 17

Hi @prash_
,

You can use :

https://doc.dataiku.com/dss/latest/preparation/processors/create-if-then-else.html
Or use nested IFs in formula: "if(condition, true, if(condition, true, false))" to do nested if/else if.

If the complexity it high to handle you can use Python Function in prepare recipe instead.

https://knowledge.dataiku.com/latest/data-preparation/prepare-recipe/reference-prepare-recipe-python-step.html

```def process(row):
ASIA = row['ASIA']  # Replace 'ASIA' with the actual column name for Asia values
TOTAL = row['TOTAL']  # Replace 'TOTAL' with the actual column name for Total values
TOTAL_CONTABLE = row['TOTAL_CONTABLE']  # Replace 'TOTAL_CONTABLE' with the actual column name for Total Contable values

if ASIA == 0:
return "CERO"
elif ASIA <= 1:
if ASIA >= -1:
return "DENTRLRANCIA"
elif ASIA > 0:
return "DIFERETIVA"
else:
return "DIFERENTIVA"
elif TOTAL == 0:
return "DIOT"
elif TOTAL_CONTABLE == 0:
return "CONTABLE"
elif ASIA > 0:
return "DIFER POSI"
else:
return "DIFERNEGVA"```

Help me…