# Nested IF with OR

Solved!
Level 1
###### Nested IF with OR

Hi Guys,

I'm struggling to write the following formula using IF and OR

IF Anp_SPIKE_Class_lead1 is equal to '1' OR Anp_SPIKE_Class_lead2 is equal to '1' then Fill in '1' ELSE Fill in '0' END

IF (OR Anp_SPIKE_Class_lead1==1,  Anp_SPIKE_Class_lead2==1, 1, 0)

Any help would be greatly appreciated.

Thank you.

2 Solutions

You have not said where in DSS you are trying to write this formula.  I'm going to guess that you are trying to use a visual recipe formula step.

In that case you were very close.  You might try an extra set of "(" and ")" and the functions "if" and "or" are case sensitive.  Try something like this.

if(or(Anp_SPIKE_Class_lead1==1,  Anp_SPIKE_Class_lead2==1), 1, 0)

I hope that help out.

Here is a link to a related conversation if the above does not work out for you.

https://community.dataiku.com/t5/Using-Dataiku-DSS/Nested-IF-with-OR-inbetween/td-p/10987

Welcome to the Dataiku Community.

--Tom
Level 1
Author

Superb! Thank you, Tom.

2 Replies

You have not said where in DSS you are trying to write this formula.  I'm going to guess that you are trying to use a visual recipe formula step.

In that case you were very close.  You might try an extra set of "(" and ")" and the functions "if" and "or" are case sensitive.  Try something like this.

if(or(Anp_SPIKE_Class_lead1==1,  Anp_SPIKE_Class_lead2==1), 1, 0)

I hope that help out.

Here is a link to a related conversation if the above does not work out for you.

https://community.dataiku.com/t5/Using-Dataiku-DSS/Nested-IF-with-OR-inbetween/td-p/10987

Welcome to the Dataiku Community.

--Tom
Level 1
Author

Superb! Thank you, Tom.