Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Multiple and complex IFs statements

filipembribeiro
6 - Meteoroid

I have a formula which returns in a new column a category depending of the date and its members:

 

IF    [DateTime_Out]>=[Date_Evaluation_Start]      AND [DateTime_Out]<="2023-01-21"
THEN IF     [Car]=="Toyota"              THEN "Big"
ELSE IF    ([Car]=="Fiat"    OR    [Car]=="Ford"   OR [Car]=="Audi"    OR    [Car]=="Peugeot")
THEN     "Medium"

ELSE      "Little"

ENDIF

AND
IF    [DateTime_Out]>="2023-01-22"
THEN IF    [Car]=="Toyota"    OR    [Car]=="Ford"    OR    [Car]=="Audi")
THEN    "Big"
ELSE IF    [Car]=="Fiat"    OR    [Car]=="Peugeot"
THEN    "Medium"
ELSE    "Little"
ENDIF

 

Is there a way to make this work?

Thank you!!!

4 REPLIES 4
Luke_C
17 - Castor
17 - Castor

Hi @filipembribeiro 

 

The below should hopefully work - some sample data is always helpful. 

 

I updated some things to alteryx syntax (i.e. ElseIf is one word, no Then Ifs, used in clauses

IF    [DateTime_Out]>=[Date_Evaluation_Start]      AND [DateTime_Out]<="2023-01-21" AND     [Car]="Toyota"              
THEN "Big"
ELSEIF   [DateTime_Out]>=[Date_Evaluation_Start]      AND [DateTime_Out]<="2023-01-21" AND [Car] in("Fiat","Ford","Audi","Peugeot")
THEN     "Medium"

ELSEIF  [DateTime_Out]>=[Date_Evaluation_Start]      AND [DateTime_Out]<="2023-01-21"
Then  "Little"

Elseif [DateTime_Out]>="2023-01-22" AND [Car] In ("Toyota","Ford","Audi")
THEN    "Big"
ELSEIF   [DateTime_Out]>="2023-01-22"  And [Car] in("Fiat","Peugeot")
THEN    "Medium"
ELSE    "Little"
ENDIF

 

 

ShankerV
17 - Castor

Hi @filipembribeiro 

 

The syntax for complex IF statements is below.

ShankerV_0-1675777677299.png

 

Was very difficult to get understand what is been trying to achieve as an output from your formula.

 

If you are able to share the input, and expected output and logic to be applied. 

Can suggest the good IF condition which will work for you.

 

 

 

binuacs
21 - Polaris

@filipembribeiro updated the formula

 

binuacs_0-1675777836054.png

 

dYoast
11 - Bolide

Hi @filipembribeiro 

 

My thought:

IF [DateTime_Out]>=[Date_Evaluation_Start] AND [DateTime_Out]<="2023-01-21" THEN 
	IF [Car] = 'Toyota' THEN
		'Big'
	ELSEIF [Car] IN ('Fiat', 'Ford', Audi', 'Peugeot') THEN
		'Medium'
	ELSE
		'Little'
	ENDIF
ELSEIF [DateTime_Out]>="2023-01-22" THEN
	IF [Car] IN ('Toyota', 'Ford', 'Audi') THEN
		'Big'
	ELSEIF [Car] IN ('Fiat', 'Peugeot') THEN
		'Medium'
	ELSE
		'Little'
	ENDIF
ELSE
	'No Match'
ENDIF
Labels