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

Alteryx designer Discussions

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

Converting a value to negative based on IF condition

Highlighted
Asteroid

I have 2 fields in my data - "Amount" & "Indicator". Amount has all positive numbers (e.g. 3.2, 0.1, 10 etc.). Indicator has either "credit" or "debit" in it. I need to write an if condition so that the values in the amount field get converted to negative number if the indicator is "credit" and remains positive otherwise. 

 

I tried a code like this

 

IF [indicator]= "credit"
THEN [amount] = (-1)*[amount]
ELSE [amount]=[amount]
ENDIF

 

but this returns me 0 for all debit values and -1 for all credit values. Any suggestions on how to do it correctly?

 

Thanks in advance

Alteryx Certified Partner
Alteryx Certified Partner
IF [indicator]= "credit"
THEN (-1)*[amount]
ELSE [amount]
ENDIF

Cheers,
Mark
Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and reboot. Order shall return.
Asteroid

Thank you. this works

Labels