Trying to write an IF function that will say "if [transaction type] = "Void" or if [transaction type] = "Refund" then [Purchase Amount] *-1
Basically trying to say if Transaction Type column is Void or Refund then I need the Purchase Amount column to be multiplied by -1. Any tips?
Solved! Go to Solution.
you've already got it, you just need to finish the statement with "endif"
you also need and "else" statement to cover cases where the if statement is false
if [Txn Type] = 'Void' or [Txn Type] = 'Refund' then
[Purchase Amt] * -1
else
[Purchase Amt]
Endif
You need to provide an 'ELSE' clause i.e. what to do if the txn type isn't void or refund, and then end your statement with 'ENDIF' to finish. Something like this for example:
IF [Txn Type] IN ('Void','Refund') THEN -[Purchase Amt] ELSE [Purchase Amt] ENDIF
The above will just return the Purchase Amount as normal (not multiplied by -1) if the Txn Type isn't void or refund. I've also used the 'IN' function so you can just provide a list of possibilities instead of constantly having to type out 'or Field Name = Value'.
Still getting errors
You need to name the new column.