Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Converting a value to negative based on IF condition

GaRaGe
8 - 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

2 REPLIES 2
MarqueeCrew
20 - Arcturus
20 - Arcturus
IF [indicator]= "credit"
THEN (-1)*[amount]
ELSE [amount]
ENDIF

Cheers,
Mark
Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
GaRaGe
8 - Asteroid

Thank you. this works

Labels