Free Trial

Alteryx Designer Desktop Discussions

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

Filling in a column based on the vale of multiple rows and columns.

edmonj
6 - Meteoroid

Looking for a way I can fill in a column at the end of my crosstab with target values for the most recent week in the rows that correspond with that target.

 

I have a data set that originally looks like this:

 

WeekThing1Thing2Thing3Thing4Target1Target2Target3Target4
1621481014735116331932
2366373186360183257296
323870124122333190313189
4394141956519433512451
53527217288608534556

 

That I transpose and crosstab to get to this:

 

KeyName12345WoWTarget
1Thing162366238394352-10.7% 
2Thing2148377014172-48.9% 
3Thing310311249517281.1% 
4Thing414786122658835.4% 
5Target135136033319460-69.1% 
6Target216318319033585-74.6% 
7Target3319257313124345178.2% 
8Target43229618951569.8% 

 

I'm looking for a way to have the target column show the latest week in the case 5 target for each Thing.

 

So the end result would look like this (I'll have to add a % to target as well but if I can get how to bring the target over this isn't an issue):

KeyName12345WoWTarget% to Target
1Thing162366238394352-10.7%60586.7%
2Thing2148377014172-48.9%8584.7%
3Thing310311249517281.1%34549.9%
4Thing414786122658835.4%56157.1%

 

I've tried a few things but have yet to get anything that works.  I'm open to either adding it in before transposing and cross tab, but I add the keys after the cross tab to order my report render accordingly and thought it would be an easy thing to reference as out of my 59 rows/keys only 12 have targets.

10 REPLIES 10
DavidSkaife
13 - Pulsar

Hi @edmonj 

 

Here is one way you could do it:

 

DavidSkaife_1-1676578993427.png

 

Transpose the data into a vertical alignment, then filter on where Name contains "Thing", Cross Tab as normal on the True output, but on the False output (which contains the "Target" section) sort by Week and Name (to ensure its in the right order for the next stage). Using the Summerise tool group by Name and find the last value, replace "target" with "Thing", join back together and sort on Name to get the final output.

 

You can then add in the other fields/calcs you may need.

 

This should also be dynamic so if you had Target/Thing6, 7, 8 etc it will handle it without any tweaking.

binuacs
21 - Polaris

@edmonj what is the logic to calculate WOW% and Targt %

edmonj
6 - Meteoroid

This works up to the point of the join back.  Where I have other 'things' that don't have targets the join is excluding them.

edmonj
6 - Meteoroid

WoW is just ([5] - [4]) / [4].

% to target will just be last week vs the target so in this case [5] / target

BS_THE_ANALYST
14 - Magnetar
14 - Magnetar

@edmonj got carried away with this one. Was enjoying trying to figure out your calculations:

BS_THE_ANALYST_0-1676581229851.png

BS_THE_ANALYST_1-1676581234509.png

It's pretty dynamic. I know you likely will be changing the names of 'Things'. If you keep the names of the columns with TargetX this should always work I think. The only thing you need to change in the workflow as more weeks get added:

BS_THE_ANALYST_2-1676581331691.png

 

 

 

All the best,
BS

LinkedIN

Bulien
DavidSkaife
13 - Pulsar

Hi @edmonj 

 

In that case you should be able to add a Union tool after the join, and bring the Left output back into the workstream

 

 

edmonj
6 - Meteoroid

@DavidSkaife that works perfectly.  thank you.

BS_THE_ANALYST
14 - Magnetar
14 - Magnetar

@edmonj okay, it should be completely dynamic now. The WoW, Target, and % to target will be automatically calculated as you add more weeks to the input.

BS_THE_ANALYST_0-1676583078041.png

 

All the best,
BS

LinkedIN

Bulien
edmonj
6 - Meteoroid

@BS_THE_ANALYST

Thank you for this as well.  One of the other things I needed to figure out eventually was getting the WoW and everything to update without me manually changing the weeks before my final output so this will be useful.

Labels
Top Solution Authors