Alteryx Designer Desktop Discussions

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

Substract a field from a previous

User12
7 - Meteor

Hi everyone,

 

Thank you for reading this :)

 

I've attached a workflow below, so you can see, that we have a dataset with 27 fields, but 2 of them will be not included in calculations.

Our input data looks like this. It is cumulative. We need to substract current month from next.

NumberNameJan-19Feb-19Mar-19Apr-19May-19Jun-19Jul-19Aug-19Sep-19Oct-19Nov-19Dec-19Jan-20Feb-20Mar-20Apr-20May-20Jun-20Jul-20Aug-20Sep-20Oct-20Nov-20Dec-20
401Revenue1970102931592121229243422510332159398104272544384491535126495101445422383299413224932647383613890339521444735070851589

 

What is the end result, that would be great to see:

NumberNameJan-19Feb-19Mar-19Apr-19May-19Jun-19Jul-19Aug-19Sep-19Oct-19Nov-19Dec-19Jan-20Feb-20Mar-20Apr-20May-20Jun-20Jul-20Aug-20Sep-20Oct-20Nov-20Dec-20
401Revenue1970832356285308311376170567651291516594769211195104944792975582308398571454261849526235881

 

First 2 fields could be dynamic, so end user should be able to choose which fields are not with values.

How do I see a workflow:

Split an input data into 2 datastreams. First contains "Number" and "Name" fields, that will not be used, and second - the rest of data.

We need to substract next column from current, but there are many periods, so we don't need to do it with the first month of year, so we need to make some kind of "Row-1" formula, but with fields, that will mean "if (contains[jan-19],"19") then [feb-19]-[jan-19] else [jan-19]). 

But the trick is that [Jan-19] is first month, so how do we keep it?

 

P.S. We may have data with more years.

6 REPLIES 6
grazitti_sapna
17 - Castor

@User12 , you can achieve this by using transform tools. Please find my solution and let me know if you need any assistance with the workflow.

 

grazitti_sapna_0-1669880817781.png

 

Sapna Gupta
Felipe_Ribeir0
16 - Nebula

Hi @User12 

 

One way of doing this

 

Felipe_Ribeir0_0-1669880866774.png

 

User12
7 - Meteor

Thank you for a response, but you see, I needed formula to substract values within periods, so that in result we will not do any manipulations with first month of period. In your solution we've got this:

User12_0-1669903727717.png

Anyway, thank you for help :)

User12
7 - Meteor

Thank you for help! That's what I wanted :)

 

Could I ask you one more question?

Your criteria in formula is based at Date ( If month is not equal 1, then it makes calculations )

But I may have a bit more complicated input, where we do not have full date (only Jan-19,Feb-19,...Jan-20... for instance).

Maybe we can somehow let formula understand that we have 12 periods without date?

 

I will attach more realistic dataset

Felipe_Ribeir0
16 - Nebula

Hi @User12 

 

Instead of using month != 1, you can use left(month, 3) != 'Jan'

 

Take a look at the attached workflow.

 

Felipe_Ribeir0_0-1669912626395.png

 

User12
7 - Meteor

Thank you a lot!

Labels