We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

How to add rows in column with same numbers but make them negative

Smiller100
7 - Meteor

Hello,

 

I have data with two columns that look like the following:

 

Order IDAmount
123456194.28
018417480.17
1047721,294.29

 

I want to create new rows in the Amount field with the negative balance of the amount for each Order ID, such as the following:

 

Order IDAmount

123456

194.28
123456-194.28
018417480.17
018417-480.17
1047721,294.29
104772-1,294.29

 

Any ideas for a quick formula to accomplish this? I'm assuming it will happen in a Generate Rows tool, but I think a Multi-Row Formula tool would work as well? Anything helps! Thank you

3 REPLIES 3
Luke_C
17 - Castor
17 - Castor

Hi @Smiller100 

 

Try something like this:

 

Essentially convert the numbers to negative and union back with the original data set. Note: I changed your input data to remove commas so Alteryx would automatically recognize it as numeric.

 

Luke_C_0-1629726980595.png

 

 

atcodedog05
22 - Nova
22 - Nova

Hi @Smiller100 

 

Adding to @Luke_C solution here is another way to do it.

 

Workflow:

atcodedog05_0-1629727170888.png

 

Hope this helps : )

 

AngelosPachis
16 - Nebula

Hello @Smiller100 ,

 

Since you want to generate a single new row per record, you can use a generate rows tool and set the number of new rows generated to 2. Then you can use a formula tool and an IF expression, to make the new rows generated a negative amount.

AngelosPachis_0-1629727268306.png

 

You might want to pay attention to the data type, as your Amount column originally is a string. You can either keep it as is, or convert it to a numeric data type.

 

Hope that helps,

Angelos

Labels
Top Solution Authors