Alteryx Designer Desktop Discussions

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

QUESTION --> IF c THEN t ELSE f ENDIF

PedroPerdomo
7 - Meteor

Hi There,

good morning,

 

I am stuck trying to get a Workflow done, this is my issue: in a table I have different customers under [consignee names] but each customer goes to a different terminal (new column that i would like to create with that terminal, so I did a formula using IF for the first customer, but I don't know how to create it for the next customers.

 

Ex (everything ok through here). 

IF [Consignee Name]="Customer1" THEN "Column AA" ELSE "" ENDIF

 

So I need to continue the formula adding

Customer 2 to Column AB

Customer 3 to Column CD 

etc etc.

 

Any help I will appreciate it.

Thanks in advance,

 

 

 

 

15 REPLIES 15
SamDesk
11 - Bolide

Hello @PedroPerdomo,

 

You can do this using the ELSEIF functionality in the Formula tool:

IF [Consignee Name] = "Customer1" THEN "Column AA" 
ELSEIF [Consignee Name] = "Customer2" THEN "Column AB" 
ELSEIF [Consignee Name] = "Customer3" THEN "Column CD" 
ENDIF

Hope that helps!

 

Sam :)

PedroPerdomo
7 - Meteor

Hi Sam, 

thank you, 

but i am still getting Malformed if Statement and ENDIF (shows with a red underline).

you know why?

PedroPerdomo
7 - Meteor

2018-11-14 12_19_59-Window.jpg

SamDesk
11 - Bolide

Hello @PedroPerdomo

 

Apologies I forgot to add in the final ELSE statement into the IF statement. It always requires an ELSE statement for any other values that are passed through the formula and if they're not important then I would usually just set them to NULL.

 

Amended Formula:

IF [Consignee Name] = "Customer1" THEN "Column AA" 
ELSEIF [Consignee Name] = "Customer2" THEN "Column AB" 
ELSEIF [Consignee Name] = "Customer3" THEN "Column CD" 
ELSE Null()
ENDIF

 

Sam :)

PedroPerdomo
7 - Meteor

THANK YOU SO MUCH SIR

its work

SamDesk
11 - Bolide
No problem @PedroPerdomo.

If you could just mark my previous post as the solution that would be great!

Sam :)
TRW
6 - Meteoroid

Adding onto this thread instead of starting a new one.

 

I'm getting the same error message.  I've tried ELSE null (), I've tried caps, lowercase, splitting END and IF into two, adding another ELSE IF, and so on.  I can't figure out why Alteryx won't accept the formula despite indicating that the formula is good since all the text is color coded!  

 

These If/then formulas are enormously frustrating, each and every time I try to write one, for this same reason.  That speaks to user error but I have no idea what I am doing wrong or why, since I'm following accepted practices.  Rant over, sorry.

 

Formula and image below.

 

Thanks

 

IF [EVENT_NAME] = "Add" THEN "Data Added" Else IF [EVENT_NAME] ="Foldering" Then "Data Foldered" Else IF [EVENT_NAME] = "Display" Then "Data Opened" Else IF [EVENT_NAME] =
"Download" Then "Data Downloaded" Else IF
[DELIVERY_DESTINATION] = "attached_printer" And [EVENT_TYPE] = "page" Then "Page Printed" Else IF [DELIVERY_DESTINATION]="Download" And [EVENT_TYPE] = "page" Then "Page Download" Else IF [DELIVERY_DESTINATION]="Email" And [EVENT_TYPE] = "page" Then " Page Emailed" Else IF [EVENT_NAME]="Blocking" Then "Data Blocked"
Else "" ENDIF

 

ChrisTX
15 - Aurora

Remove the space between Else and If

 

Use ElseIf

 

To see the correct format for all functions: on the Functions page, click the third icon for Expand All

https://help.alteryx.com/current/Reference/Functions.htm

 

Then search for "IF"

 

Capture.PNG

TRW
6 - Meteoroid

I'll be darned.  Thanks, Chris.  

 

I wonder why Alteryx doesn't give me an error after that first incorrect space instead of saying that the error is at the very end.  That would have saved me quite a bit of frustration.

Labels