Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
Alteryx is here to help you solve your biggest data challenges. Read about the new Virtual Solution Center here.
SOLVED

Subtraction from cell above

Highlighted
8 - Asteroid

Hi,

 

I am trying to do a formula involves with subtraction from the cell above.

 

Original:

 AB
1Transaction#Amount

2

AAA

4,000
3BBB2,000
4CCC-2,000
5DDD3,000
6EEE-3,000
7FFF6,000
8GGG-6,000

 

After:  the new column in C is where the result would be from column D. 

 

 ABCD
1Transaction#AmountNet Zero Trans.Calculation in Excel in C (don't need this column)
2AAA4,0004,000=IF(OR(B2+B1=0,B2+B3=0),0,B2)
3BBB2,0000=IF(OR(B3+B2=0,B3+B4=0),0,B3)
4CCC-2,0000=IF(OR(B4+B3=0,B4+B5=0),0,B4)
5DDD3,0000=IF(OR(B5+B4=0,B5+B6=0),0,B5)
6EEE-3,0000=IF(OR(B6+B5=0,B6+B7=0),0,B6)
7FFF6,0000=IF(OR(B7+B6=0,B7+B8=0),0,B7)
8GGG-6,0000=IF(OR(B8+B7=0,B8+B9=0),0,B8)

 

Please help!

 

Thanks,

Highlighted
Alteryx Partner

You'll want to look into the Multi Row Formula Tool.

 

You can do what you're looking for with the following expression:

 

[Row-1:Net Zero Trans.] + [Amount]

 

This will take the value above it in the Net Zero Trans. column, and add the Amount in the current row. You could turn this to subtract if you wanted easily. 

 

Then, just remember to configure the tool to create a New Field, and name it Net Zero Trans.

 

Let me know if you need more assistance,

 

Cheers!

 

EDIT: Here's a screenshot of the formula in action:

 

Spoiler
multirowsubtract.PNG
Highlighted
Alteryx
Alteryx

Hi @yzhang316,

 

Thanks for your question! To achieve your desired result, use a 'Multi-Row Formula' tool. Please see the below screenshot and attached workflow for details on how to set up. 

 

net zero trans.png

Highlighted
8 - Asteroid

Thanks for the reply! 

 

This is where I got stuck actually.  I was able to add the new column and do the addition formula, but I don't do how to do the "OR" formula in there.  In excel it would be =IF(OR(B2+B1=0,B2+B3=0),0,B2), if B2+B1=0 or B2+B3=0 then 0 else B2.  

Highlighted
8 - Asteroid

Thank you!  your magic worked and I learn something new today!

Labels