Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Calculate difference within a column

mphillips27
7 - Meteor

Hello,

I have data that is grouped by groups (group 1, group 2, etc) and then sorted by the meeting date of that group. We are tracking the difference of several values between the latest meeting date and previous meeting date. So the original data looks like below

GroupTileMeeting dateValueValue 2Value 3
group 1110/1/2021100100100
group 129/1/2021505050
group 2110/1/2021400400400
group 229/1/2021300300300
group 3110/1/2021800800800
group 329/1/2021600600600
group 4110/1/2021200200200
group 429/1/2021100100100

 

What I would like to do is calculate the difference between each groups latest and previous meeting. So one desired result would be this

 

GroupTileMeeting dateValueValue 2Value 3     
group 1110/1/2021100100100     
group 129/1/2021505050     
group 23 505050 < -- Variance between first meeting - second meeting
group 2110/1/2021400400400     
group 229/1/2021300300300     
group 33 100100100 < -- Variance between first meeting - second meeting
group 3110/1/2021800800800     
group 329/1/2021600600600     
group 43 200200200 < -- Variance between first meeting - second meeting
group 4110/1/2021200200200     
group 429/1/2021100100100     
group 53 100100100 < -- Variance between first meeting - second meeting

 

or another result could be that it updates the 9/1/21 value with the difference instead of inserting a row for the difference like this

 

GroupTileMeeting dateValueValue 2Value 3     
group 1110/1/2021100100100     
group 23 505050 < -- Variance between first meeting - second meeting
group 2110/1/2021400400400     
group 33 100100100 < -- Variance between first meeting - second meeting
group 3110/1/2021800800800     
group 43 200200200 < -- Variance between first meeting - second meeting
group 4110/1/2021200200200     
group 53 100100100 < -- Variance between first meeting - second meeting

 

I'm assuming this is done with a multirow formula tool but not sure how! thanks!

5 REPLIES 5
csmith11
11 - Bolide

See solution attached.

 

Please let me know if this satisfies your requirements.

csmith11
11 - Bolide

This should satisfy the requirements for the second option. 

atcodedog05
22 - Nova
22 - Nova

Hi @mphillips27 

 

My take on this.

 

Workflow:

atcodedog05_0-1635516366459.png

 

Hope this helps : )

 

csmith11
11 - Bolide

@atcodedog05 's take is a much more clever approach. Frankly, its the better solution. 

 

As bonus if the number of values many increase or decrease (could there be a value 4, value 5, value 6) you may consider Transposing before and cross tabbing after the summarize tool to make this workflow more dynamic. You'll also have to check the Dynamic or Unknown Fields option in the Multi Field Formula tool.

 

csmith11_2-1635517254440.png

 

 

atcodedog05
22 - Nova
22 - Nova

Hi @csmith11 

 

Agreed, adding (transpose)-(summarize)-(crosstab) can definitely make the workflow dynamic 🙂

Labels