Start Free Trial

Alteryx Designer Desktop Discussions

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

Subtract Columns from each other dynamically

bigdatadan23
5 - Atom

Hello Alteryx Forum,

 

I am trying to figure out a solution to this and was wondering if possible. Right now I have this data. 

 

2024_05_132024_05_202024_05_27C_Value
2472254725732502
1821178517931785

 

I would want to subtract "C_Value" from "2024_05_27", but also want the operation to work dynamically when the penultimate field name changes when the week changes. Is there any way to achieve this?

 

Thanks in advance

4 REPLIES 4
tim-regas
8 - Asteroid

@bigdatadan23 Assuming you are always looking to subtract C_Value from the most recent column of data. I would use the dynamic rename tool to rename the most recent data to a static name and then perform the subtraction using the dynamic column name.Dynamic Column Subtraction.png

leozhang2work
10 - Fireball

Given the first few columns are the same type, another way to go would be pivot long those.

Then apply your dynamic logic through a filter tool, join/append back the c_values.

It is easier to implement the logic on rows rather than columns, and you can pivot the results back to columns if it is required in that form.

danilang
19 - Altair
19 - Altair

Hi @bigdatadan23 

 

Similar in concept to @tim-regas solution, but somewhat simpler in execution

 

w.png

This uses a Field Info tool to build a new name for the penultimate column which is changed to  __RenamedColumn__ by the first Dynamic Rename.  The formula tool subtracts C_Value from this and the second Dynamic Rename restores the original column names

 

Dan

 

jdminton
13 - Pulsar

Based on @leozhang2work 's suggestion, you could do something like this to make it dynamic.

 

Snag_71012822.png

Labels
Top Solution Authors