ALTERYX INSPIRE | Join us this May for for a multi-day virtual analytics + data science experience like no other! Register Now
alteryx Community

# Alteryx Designer Discussions

SOLVED

## Subtraction from cell above

8 - Asteroid

Hi,

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

Original:

 A B 1 Transaction# Amount 2 AAA 4,000 3 BBB 2,000 4 CCC -2,000 5 DDD 3,000 6 EEE -3,000 7 FFF 6,000 8 GGG -6,000

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

 A B C D 1 Transaction# Amount Net Zero Trans. Calculation in Excel in C (don't need this column) 2 AAA 4,000 4,000 =IF(OR(B2+B1=0,B2+B3=0),0,B2) 3 BBB 2,000 0 =IF(OR(B3+B2=0,B3+B4=0),0,B3) 4 CCC -2,000 0 =IF(OR(B4+B3=0,B4+B5=0),0,B4) 5 DDD 3,000 0 =IF(OR(B5+B4=0,B5+B6=0),0,B5) 6 EEE -3,000 0 =IF(OR(B6+B5=0,B6+B7=0),0,B6) 7 FFF 6,000 0 =IF(OR(B7+B6=0,B7+B8=0),0,B7) 8 GGG -6,000 0 =IF(OR(B8+B7=0,B8+B9=0),0,B8)

Thanks,

12 - Quasar

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
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.

8 - Asteroid