Free Trial

Alteryx Designer Desktop Discussions

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

Flat file - Subtract other row with precondition

ernesttpr
5 - Atom

Hi, how do I subtract another row in a flat file with precondition. 
What I'm trying to do is - if Major Heading column is 'Sales', then I would like to subtract the 'Amount' for the 'Period' 'Jun-20' from 'May-20' with the same 'Account Code / Name'

 

ernesttpr_0-1646257936509.png

 

4 REPLIES 4
DavidSkaife
13 - Pulsar

Hi @ernesttpr 

 

Please see attached solution. A filter to restrict to just Sales rows, a crosstab grouped by the field(s) you require, the headers being the Periods, and the value being the amount. A formula tool to then subtract one field from the other.

 

DavidSkaife_1-1646259129484.png

 

The formula tool can be expanded to include multiple calculations if required

 

Cheers,

 

David

ernesttpr
5 - Atom

Hi - Thanks that was helpful. I should have been more specific, there are actually 12 months in the 'Period' Column, thus trying to achieve the below.

 

If Major Heading column is 'Sales', then I would like to subtract the 'Amount' for the 'Period' 'Jun-20' from 'May-20' with the same 'Account Code / Name'. If 'Period' is 'May'20', then I would like to subtract the 'Apr-20' 'Amount' following the same logic. Would need to do the same for periods Feb-20 to Dec-20, however if the value is Jan-20, then no subtraction is needed.

 

There are also 10 distinct values in Major Heading Column, and I'm trying to do the above logic for 5 of them.

 

Thanks in advance!

DavidSkaife
13 - Pulsar

Hi @ernesttpr How would you like the output to look? I can expand the workflow to take into account the logic but an understanding of the end result would be good.

ernesttpr
5 - Atom

Hi David,

Thanks! I've actually managed to work it out.

Labels
Top Solution Authors