community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

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

IF Statement FOR Negative numbers

Highlighted
Asteroid

Hi Alteryx Team

 

I have a problem with formulating this IF statement. Basically if the the person is indian, match and above amt of +/-20000000 Then the Age should add by 1.

So I applied the formula and it worked great but when it comes to negative number eg:

Age IndianAmtType
1Yes-28000000Match
4Yes126000000Match
10No36000000Match

 

and using this in formula tool 

IF [Indian]="Yes"
AND [Type]="Match"
AND [Amt]>=20000000
THEN [Age]+1
ELSE [Age]+0
ENDIF

 

The output arrives at 

AgeIndianAmtType
1Yes-28000000Match
5Yes126000000

Match

10No36000000

Match

 

while for negative numbers above 20000000 it should add to the age. Like so -

AgeIndianAmtType
2Yes-28000000Match
5Yes126000000Match
10No36000000Match

 

How do I arrive at this output even with negative numbers??

 

I tried using this formula too but it still doesn't seem to work

IF [Indian]="Yes"
AND [Type]="Match"
AND [Amt]>=20000000 OR  [Amt]>=-20000000
THEN [Age]+1
ELSE [Age]+0
ENDIF

 

Appreciate your help

Meteor

I think this should work....

 

IF [Indian]="Yes"
AND [Type]="Match"
AND (IIF([Amt]<0,[Amt]*-1,[Amt])) >= 20000000
THEN [Age]+1
ELSE [Age]
ENDIF

Quasar

I would use following formula.

 

iif([Indian]="Yes" and ([Amt]>20000000 or [Amt]<-20000000) and ([Type]="Match"), [Age ]+1,[Age ])

 

workflow.PNG

 

 

Alteryx
Alteryx

In Alteryx, there are almost always multiple ways to do things. I would go with

 

IF [Indian]="Yes"
AND [Type]="Match"
AND ABS([Amt]) >= 20000000
THEN [Age]+1
ELSE [Age]
ENDIF

Labels