Join the Alteryx Community’s Maveryx Summer Cup event! Compete, network with others, and earn your gold through a series of challenges from July 24th to August 11th. Learn more about the event here.

Alteryx Designer Desktop Discussions

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

Conversion of Excel three nested IF statement to Alteryx

Hamster
7 - Meteor

I have the follow Excel IF statement that I need translated in Alteryx.

=IF(H6="CASH",IF(AB6<0,"CRO","CGO"),IF(AB6<0,"ORO","OGO")).

 

I've been able to get this far but it's returning a Parse Error at Char(135).

IF [A]='CASH' THEN (IF [B]<0 THEN 'CRO' ELSE 'CGO'
endIF)
else
(if [B]<0 THEN 'ORO' ELSE 'OGO' endIF)

 

Any help would be appreciated.

5 REPLIES 5
BrandonB
Alteryx
Alteryx

I think that something like this might work for you

 

IF [A]='CASH' AND [B]<0

THEN 'CRO'

ELSEIF IF [A]='CASH' AND [B]>=0

THEN 'CGO'

ELSEIF [AB]<0

THEN 'ORO'

ELSE 'OGO'

ENDIF

PaulNo
10 - Fireball

Hi @Hamster,

 

You have done all the work so congrats!

 

You are missing the "endif" to match the initial "if" 🙂

 

Thanks,

 

PaulN

Hamster
7 - Meteor

Hi PaulN

 

If I add the EndIF after the last ')' I get another error message saying Invalid type in operator <.

This is the formula now.

IF [a]='CASH' THEN (IF [b]<0 THEN 'CRO' ELSE 'CGO'
endIF)
else
(if [b]<0 THEN 'ORO' ELSE 'OGO' endIF) endif

RolandSchubert
16 - Nebula
16 - Nebula

Hi @Hamster ,

 

I think, it's a data type related problem - is [b] a numeric field (INT, DOUBLE)? Using ToNumber([b]) should solve this.

 

Try:

IF [a]='CASH' THEN
   IF ToNumber([b]) < 0 THEN
      'CRO'
   ELSE
      'CGO'
   ENDIF
ELSE
   IF ToNumber([b]) < 0 THEN
      'ORO'
   ELSE
      'OGO'
   ENDIF
ENDIF

 

Btw: The brackets are not needed, 

 

Let me know if it works for you now.

 

Best,

 

Roland

Hamster
7 - Meteor

Thanks Roland - [b] was a calculated field but had String as it's data type, changing this to double fixed my formula.

Labels