Free Trial

Alteryx Designer Desktop Discussions

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

Nested If Statement

Pangulia
5 - Atom

Hi

I'm trying to create Nested IF Statement below and keep getting the  the following error message "Malformed If Statement"

 

Can anyone advise what I'm doing wrong

 

IF [Bought at Band] = 1 THEN [Variance_Band_1_per_each]*[Annualised Eaches Bought]

ELSEIF [Bought at Band] = 2 THEN [Variance_Band_2_per_each]* [Annualised Eaches Bought]

ELSEIF [Bought at Band] = 3 THEN [Variance_Band_3_per_each]* [Annualised Eaches Bought]

ELSEIF [Bought at Band] = 4 THEN [Variance_Band_4_per_each]* [Annualised Eaches Bought]

ELSEIF [Bought at Band] = 5 THEN [Variance_Band_5_per_each]* [Annualised Eaches Bought]

ENDIF

3 REPLIES 3
Felipe_Ribeir0
16 - Nebula

Hi @Pangulia 

 

You need to finish the IF statement with ELSE. If necessary, take a look at the attached workflow.

 

IF [Bought at Band] = 1 THEN [Variance_Band_1_per_each]*[Annualised Eaches Bought]

ELSEIF [Bought at Band] = 2 THEN [Variance_Band_2_per_each]* [Annualised Eaches Bought]

ELSEIF [Bought at Band] = 3 THEN [Variance_Band_3_per_each]* [Annualised Eaches Bought]

ELSEIF [Bought at Band] = 4 THEN [Variance_Band_4_per_each]* [Annualised Eaches Bought]

ELSEIF [Bought at Band] = 5 THEN [Variance_Band_5_per_each]* [Annualised Eaches Bought]

ELSE 0

ENDIF

 

Felipe_Ribeir0_0-1665052805495.png

 

 

If the provided answer helped you to solve the problem/was correct, please accept it as a solution :)

 

Thanks.

Pangulia
5 - Atom

Thanks fore the quick response. I'm Still getting an different error message now. I'm fairly new to Alteryx and can't see what I'm missing 

Formula (31) Parse Error at char(411): Formula: tried to apply numeric operator to string value (Expression #1)

 

I've added the ELSE 0 in below

 

IF [Bought at Band] = 1 THEN [Variance_Band_1_per_each]*[Annualised Eaches Bought]

ELSEIF [Bought at Band] = 2 THEN [Variance_Band_2_per_each]* [Annualised Eaches Bought]

ELSEIF [Bought at Band] = 3 THEN [Variance_Band_3_per_each]* [Annualised Eaches Bought]

ELSEIF [Bought at Band] = 4 THEN [Variance_Band_4_per_each]* [Annualised Eaches Bought]

ELSEIF [Bought at Band] = 5 THEN [Variance_Band_5_per_each]* [Annualised Eaches Bought]

ELSE 0

ENDIF

Felipe_Ribeir0
16 - Nebula

Hi @Pangulia 

 

Add a select tool before the formula tool and check the datatype of these columns:

 

[Bought at Band]

[Annualised Eaches Bought]

[Variance_Band_1_per_each]

[Variance_Band_2_per_each]

[Variance_Band_3_per_each]

[Variance_Band_4_per_each]

[Variance_Band_5_per_each]

 

Felipe_Ribeir0_0-1665054269761.png

 

The datatype of these columns must be numerical (double,float , fixed decimal or int) for this formula to work.

 

If the provided answer helped you to solve the problem/was correct, please accept it as a solution :)

 

Thanks.

Labels
Top Solution Authors