Alteryx Designer Desktop Discussions

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

How to add a new column with data from existing column but conditional

KyraM
5 - Atom

Hi, 

 

I'm trying to add a new column "Amount USD" to my dataset in Alteryx, which should be conditional to a previous column, but I can't figure out what the exact formula has to be. 

E.g.:

 

G/L AccountAmount 
Trade Sales        100.000,00
Intercompany Sales        100.000,00
Cost of Goods Sold         80.000,00
Distribution Expense         10.000,00

 

For Trade Sales and Intercompany Sales I want the column "Amount USD"  to display negative amounts of "Amount" and for the other two I want it to show "Amount".

The formula that I tried using the formula tool is as follows (I selected that I want an output column "Amount USD"):

 

IF [G/L Account]="Trade Sales" THEN "[Amount]*-1"

ELSEIF [G/L Account]="Intercompany Sales" THEN "[Amount]*-1"

ELSE [Amount]
ENDIF

 

What should I do differently? Thanks in advance!

5 REPLIES 5
PhilipMannering
16 - Nebula
16 - Nebula

Hi @KyraM 

 

This should sort you out. Your numbers were a bit awkward due to the values being strings.

PhilipMannering_0-1607345825129.png

 

Emil_Kos
17 - Castor
17 - Castor

Hi @KyraM,

 

Maybe you prefer using the join tool. I think it will be easier for you to maintain:

 

Emil_Kos_0-1607345847467.png

 

 

The output:

 

Emil_Kos_1-1607345860928.png

 

messi007
15 - Aurora
15 - Aurora

@KyraM,

 

Please see below

 

messi007_0-1607345815270.png

Attached the workflow

 

f this solves your issue please mark the answer as correct.

Regards

Emil_Kos
17 - Castor
17 - Castor

Hi @KyraM,

 

Regarding your solution. I think you just need to made a small amendment:

 

IF [G/L Account]="Trade Sales" THEN [Amount]*(-1)

ELSEIF [G/L Account]="Intercompany Sales" THEN [Amount]*(-1)

ELSE [Amount]
ENDIF

 

You need to remove brackets from the positions that you want to multiply: "[Amount]*-1"

KyraM
5 - Atom

Thanks! I didn't even notice I put brackets, but without it it seems to work, as well as the reply just above. Thanks everyone!

Labels