Survey banner
Switching to Dataiku - a new area to help users who are transitioning from other tools and diving into Dataiku!

How to write this formula in dataiku ?

Level 3
How to write this formula in dataiku ?

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

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

``````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"``````