Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

IF ELSE Statements showing Error

Sushweta
5 - Atom

I am getting error as "Malformed IF statement" 

 

IF contains([DMA],"_SafariTest")
THEN REPLACE([DMA],"_SafariTest"," Safari Test")
ELSE IF contains([DMA],"_Safari Test")
THEN REPLACE([DMA],"_Safari Test"," Safari Test")
ELSE IF contains([DMA]," SafariTest")
THEN REPLACE([DMA]," SafariTest"," Safari Test")
ELSE [DMA] ENDIF

 

Kindly help me figure out where the error is.

4 REPLIES 4
MarqueeCrew
20 - Arcturus
20 - Arcturus

ElseIf instead of Else If

 

IF contains([DMA],"_SafariTest")
THEN REPLACE([DMA],"_SafariTest"," Safari Test")
ELSEIF  contains([DMA],"_Safari Test")
THEN REPLACE([DMA],"_Safari Test"," Safari Test")
ELSEIF contains([DMA]," SafariTest")
THEN REPLACE([DMA]," SafariTest"," Safari Test")
ELSE [DMA] ENDIF


cheers,

 

 mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
huynv96
9 - Comet

You miss two ENDIF.

Capture.PNG

 

ChrisTX
15 - Aurora

In addition to the answers already provided, you might want to take a look at the Find Replace tool.

echuong1
Alteryx Alumni (Retired)

As mentioned above, look into using the find and replace tool. That way you only need to update the input tool with the find and replace mapping, rather than having additional conditional statements. This will also increase performance run times if you are using large datasources. 

 

See attached for an example. Let me know if that helps and/or if you have additional questions!

Labels