Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLUCIONADO

IF statement

Lauriek
Meteoro

Hello,

 

How do I end this expression?  It is good up to the last line, which stays blacked out (I have it bolded below).  I've tried ending with parentheses and with "else", endif.  Does anyone have suggestions?

 

IIF (contains([ProductCode],"065"), tonumber([Sum_NetUnits])*.184 OR
contains([ProductCode],"167"), tonumber([Sum_NetUnits])*.244 OR
contains([ProductCode],"227"), tonumber([Sum_NetUnits])*.001

 

Thank you,

Laurie

5 RESPOSTAS 5
atcodedog05
22 - Nova
22 - Nova

Hi @Lauriek 

 

Formula would be like

 

If contains([ProductCode],"065") then tonumber([Sum_NetUnits])*.184 
Elseif contains([ProductCode],"167") then tonumber([Sum_NetUnits])*.244
Elseif contains([ProductCode],"227") then tonumber([Sum_NetUnits])*.001

Else Null()

Endif

 

Hope this helps : )

Lauriek
Meteoro

That worked, thank you so much!!

atcodedog05
22 - Nova
22 - Nova

Happy to help : ) @Lauriek 

Cheers and have a nice day!

 

Here is a resource which might help you with this topic : https://community.alteryx.com/t5/Interactive-Lessons/Writing-Conditional-Statements/ta-p/98910 

Ben_H
Bólide

Just to add to this a little -

 

The form of IF that you had used initially "IIF" can also work as follows - 

 

IIF(contains([ProductCode],"065"), tonumber([Sum_NetUnits])*.184,
IIF(contains([ProductCode],"167"), tonumber([Sum_NetUnits])*.244,
IIf(contains([ProductCode],"227"), tonumber([Sum_NetUnits])*.001,null())))

 

It works like an Excel nested if. Although, personally I think it's easier to read the way atcodedog has suggested.

 

Regards,

 

Ben

 

 

Lauriek
Meteoro

Thank you for your solution also, I will keep both of these in mind for future use.

Rótulos