Alteryx Designer Desktop Discussions

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

Case Statement in Alteryx.

rohit782192
11 - Bolide

Hello Team,

 

How can we create a Workflow in Alteryx for SQL case statement.

CASE
    WHEN condition1 THEN result1
    WHEN condition2 THEN result2
    WHEN conditionN THEN resultN
    ELSE result
END;

4 REPLIES 4
RolandSchubert
16 - Nebula
16 - Nebula

Hi @rohit782192 ,

 

in Alteryx, you use:

 

IF condition THEN

statement

ELSEIF condition THEN
statement
ELSEIF condition THEN
statement

ELSE

statement
ENDIF

 

So the difference is - no case, first condition is "IF", other conditions are "ELSEIF", ENDIF replaces END and no semicolon needed.

 

Best,

 

Roland

amruthas2
8 - Asteroid

You can use Switch statement in Alteryx.

 

Example - 
Month
01

02

03

 

Output Expected -

Jan

Feb

Mar

 

Create Formula - 

Switch(

ColumnName,"Default Value",

"01", "Jan",

"02","Feb",

"03","Mar"

)

 

rohit782192
11 - Bolide

Thanks

 

This work for me a Switch Statement in Alteryx.

 

Switch(
[Month],"Default Value",
"01", "Jan",
"02","Feb",
"03","Mar",
"04","April",
"05","May",
"06","June",
"07","July",
"08","August",
"09","September",
"10","October",
"11","November",
"12","December"
)

 

Output

 

Month Output
01 Jan
02 Feb
03 Mar
04 April
05 May
06 June
07 July
08 August
09 September
10 October
11 November
12 December

 

 

 

Luke_C
17 - Castor

Hi @rohit782192 

 

If your data is the months, you can go simpler with the datetime functions:

DateTimeFormat(DateTimeParse([Month],'%m'),'%B')

 

Luke_C_0-1649258900963.png

 

Labels